Complete Vue.js 2 Web Development_ Practical guide to building end-to-end web development solutions with Vue.js 2

(singke) #1
Organize + Automate + Deploy = Webpack Chapter 16

Let's get rid of some plugins that we don't need for releasing a library; find the plugins


array inside the file. It's an array containing plugins in the form of the following code:


plugins: [
new Plugin1(...),
new Plugin2(...),
...
new PluginN(...)
]

We only need the following plugins:


webpack.DefinePlugin
webpack.optimize.UglifyJsPlugin
webpack.optimize.OccurrenceOrderPlugin

Get rid of all the other plugins as we don't need them; the final array should look like this:


plugins: [
new webpack.DefinePlugin({
'process.env': env
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.optimize.OccurrenceOrderPlugin()
]

The first one allows you to add some more configuration, the second plugin minifies the
file, and the third one will optimize the size of the resulting file.


Another property we need to edit is output, as we want to simplify the output path.


The original property looks like this:


output: {
path: config.build.assetsRoot,
filename: utils.assetsPath('js/[name].[chunkhash].js'),
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
}
Free download pdf