|
| 1 | +var webpack = require('webpack') |
| 2 | +var config = require('./webpack.base.conf') |
| 3 | +var cssLoaders = require('./css-loaders') |
| 4 | +var ExtractTextPlugin = require('extract-text-webpack-plugin') |
| 5 | +var HtmlWebpackPlugin = require('html-webpack-plugin') |
| 6 | + |
| 7 | +// naming output files with hashes for better caching. |
| 8 | +// dist/index.html will be auto-generated with correct URLs. |
| 9 | +config.output.filename = '[name].[chunkhash].js' |
| 10 | +config.output.chunkFilename = '[id].[chunkhash].js' |
| 11 | + |
| 12 | +// whether to generate source map for production files. |
| 13 | +// disabling this can speed up the build. |
| 14 | +var SOURCE_MAP = true |
| 15 | + |
| 16 | +config.devtool = SOURCE_MAP ? '#source-map' : false |
| 17 | + |
| 18 | +config.vue = config.vue || {} |
| 19 | +config.vue.loaders = config.vue.loaders || {} |
| 20 | +cssLoaders({ |
| 21 | + sourceMap: SOURCE_MAP, |
| 22 | + extract: true |
| 23 | +}).forEach(function (loader) { |
| 24 | + config.vue.loaders[loader.key] = loader.value |
| 25 | +}) |
| 26 | + |
| 27 | +config.plugins = (config.plugins || []).concat([ |
| 28 | + // http://vuejs.github.io/vue-loader/workflow/production.html |
| 29 | + new webpack.DefinePlugin({ |
| 30 | + 'process.env': { |
| 31 | + NODE_ENV: '"production"' |
| 32 | + } |
| 33 | + }), |
| 34 | + new webpack.optimize.UglifyJsPlugin({ |
| 35 | + compress: { |
| 36 | + warnings: false |
| 37 | + } |
| 38 | + }), |
| 39 | + new webpack.optimize.OccurenceOrderPlugin(), |
| 40 | + // extract css into its own file |
| 41 | + new ExtractTextPlugin('[name].[contenthash].css'), |
| 42 | + // generate dist index.html with correct asset hash for caching. |
| 43 | + // you can customize output by editing /index.html |
| 44 | + // see https://github.com/ampedandwired/html-webpack-plugin |
| 45 | + new HtmlWebpackPlugin({ |
| 46 | + filename: '../index.html', |
| 47 | + template: 'index.html', |
| 48 | + inject: true, |
| 49 | + minify: { |
| 50 | + removeComments: true, |
| 51 | + collapseWhitespace: true, |
| 52 | + removeAttributeQuotes: true |
| 53 | + // more options: |
| 54 | + // https://github.com/kangax/html-minifier#options-quick-reference |
| 55 | + } |
| 56 | + }) |
| 57 | +]) |
| 58 | + |
| 59 | +module.exports = config |
0 commit comments