|
| 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 | + fallback: "vue-style-loader", |
| 16 | + use: "css-loader" |
| 17 | + }) |
| 18 | + }, |
| 19 | + { |
| 20 | + test: /\.less/, |
| 21 | + loader: ExtractTextPlugin.extract({ |
| 22 | + fallback: "vue-style-loader", |
| 23 | + use: ["css-loader", "less-loader"] |
| 24 | + }) |
| 25 | + } |
| 26 | + ] |
| 27 | + }, |
| 28 | + devtool: '#source-map', |
| 29 | + output: { |
| 30 | + path: path.resolve(__dirname, '..', `${isProduction ? './example/dist' : 'gh-pages'}`), |
| 31 | + publicPath: isProduction ? '/' : '/scrollbar', |
| 32 | + filename: 'js/[name].[chunkhash].js' |
| 33 | + }, |
| 34 | + plugins: [ |
| 35 | + new webpack.DefinePlugin({ |
| 36 | + 'process.env': { |
| 37 | + NODE_ENV: '"production"' |
| 38 | + } |
| 39 | + }), |
| 40 | + new webpack.optimize.UglifyJsPlugin({ |
| 41 | + sourceMap: true, |
| 42 | + compress: { |
| 43 | + warnings: false |
| 44 | + } |
| 45 | + }), |
| 46 | + new ExtractTextPlugin({ |
| 47 | + filename: 'css/[name].[contenthash].css', |
| 48 | + allChunks: true |
| 49 | + }), |
| 50 | + new HtmlWebpackPlugin({ |
| 51 | + filename: 'index.html', |
| 52 | + template: 'example/index.html', |
| 53 | + inject: true, |
| 54 | + minify: { |
| 55 | + removeComments: true, |
| 56 | + collapseWhitespace: true, |
| 57 | + removeAttributeQuotes: true |
| 58 | + // more options: |
| 59 | + // https://github.com/kangax/html-minifier#options-quick-reference |
| 60 | + }, |
| 61 | + // necessary to consistently work with multiple chunks via CommonsChunkPlugin |
| 62 | + chunksSortMode: 'dependency' |
| 63 | + }) |
| 64 | + ] |
| 65 | +}) |
0 commit comments