Skip to content

Instantly share code, notes, and snippets.

@esahione
Created March 18, 2016 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esahione/c8d75d51ff7e59b10d5a to your computer and use it in GitHub Desktop.
Save esahione/c8d75d51ff7e59b10d5a to your computer and use it in GitHub Desktop.
Webpack Production Configuration
var webpack = require('webpack')
var merge = require('webpack-merge')
var baseConfig = require('./webpack.base.conf')
var cssLoaders = require('./css-loaders')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var HtmlWebpackPlugin = require('html-webpack-plugin')
// whether to generate source map for production files.
// disabling this can speed up the build.
var SOURCE_MAP = true
module.exports = merge(baseConfig, {
stats: {
children: false
},
devtool: SOURCE_MAP ? '#source-map' : false,
output: {
// naming output files with hashes for better caching.
// dist/index.html will be auto-generated with correct URLs.
filename: '[name].[chunkhash].js',
chunkFilename: '[id].[chunkhash].js'
},
vue: {
loaders: cssLoaders({
sourceMap: SOURCE_MAP,
extract: true
})
},
plugins: [
// http://vuejs.github.io/vue-loader/workflow/production.html
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.optimize.OccurenceOrderPlugin(),
// extract css into its own file
new ExtractTextPlugin('[name].[contenthash].css'),
// generate dist index.html with correct asset hash for caching.
// you can customize output by editing /index.html
// see https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: '../index.html',
template: 'build/index.template.html',
inject: true,
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true
// more options:
// https://github.com/kangax/html-minifier#options-quick-reference
}
})
]
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment