|
| 1 | +var path = require('path') |
| 2 | +var webpack = require('webpack') |
| 3 | +var merge = require('webpack-merge') |
| 4 | +var baseWebpackConfig = require('./webpack.example.base.conf') |
| 5 | +var HtmlWebpackPlugin = require('html-webpack-plugin') |
| 6 | +var ExtractTextPlugin = require('extract-text-webpack-plugin') |
| 7 | +var isProduction = process.env.NODE_ENV === 'production' |
| 8 | + |
| 9 | +module.exports = merge(baseWebpackConfig, { |
| 10 | + module: { |
| 11 | + rules: [ |
| 12 | + { |
| 13 | + test: /\.css$/, |
| 14 | + loader: ExtractTextPlugin.extract({ |
| 15 | + use: "css-loader", |
| 16 | + fallback: "style-loader" |
| 17 | + }) |
| 18 | + } |
| 19 | + ] |
| 20 | + }, |
| 21 | + devtool: '#source-map', |
| 22 | + output: { |
| 23 | + path: path.resolve(__dirname, '..', `${isProduction ? './example/dist' : './gh-pages'}`), |
| 24 | + publicPath: isProduction ? '/' : '/grid', |
| 25 | + filename: 'js/[name].[chunkhash].js' |
| 26 | + }, |
| 27 | + plugins: [ |
| 28 | + new webpack.DefinePlugin({ |
| 29 | + 'process.env': { |
| 30 | + NODE_ENV: '"production"' |
| 31 | + } |
| 32 | + }), |
| 33 | + new webpack.optimize.UglifyJsPlugin({ |
| 34 | + sourceMap: true, |
| 35 | + compress: { |
| 36 | + warnings: false |
| 37 | + } |
| 38 | + }), |
| 39 | + new ExtractTextPlugin({ |
| 40 | + filename: 'css/[name].[contenthash].css', |
| 41 | + allChunks: true |
| 42 | + }), |
| 43 | + new HtmlWebpackPlugin({ |
| 44 | + filename: 'index.html', |
| 45 | + template: 'example/index.html', |
| 46 | + inject: true, |
| 47 | + minify: { |
| 48 | + removeComments: true, |
| 49 | + collapseWhitespace: true, |
| 50 | + removeAttributeQuotes: true |
| 51 | + // more options: |
| 52 | + // https://github.com/kangax/html-minifier#options-quick-reference |
| 53 | + }, |
| 54 | + // necessary to consistently work with multiple chunks via CommonsChunkPlugin |
| 55 | + chunksSortMode: 'dependency' |
| 56 | + }) |
| 57 | + ] |
| 58 | +}) |
0 commit comments