|
| 1 | +var path = require('path') |
| 2 | +var webpack = require('webpack') |
| 3 | + |
| 4 | +module.exports = { |
| 5 | + entry: './src/client-entry.js', |
| 6 | + output: { |
| 7 | + path: path.resolve(__dirname, './dist'), |
| 8 | + publicPath: '/dist/', |
| 9 | + filename: 'build.js' |
| 10 | + }, |
| 11 | + module: { |
| 12 | + rules: [ |
| 13 | + { |
| 14 | + test: /\.css$/, |
| 15 | + use: [ |
| 16 | + 'vue-style-loader', |
| 17 | + 'css-loader' |
| 18 | + ], |
| 19 | + }, |
| 20 | + { |
| 21 | + test: /\.scss$/, |
| 22 | + use: [ |
| 23 | + 'vue-style-loader', |
| 24 | + 'css-loader', |
| 25 | + 'sass-loader' |
| 26 | + ], |
| 27 | + }, |
| 28 | + { |
| 29 | + test: /\.sass$/, |
| 30 | + use: [ |
| 31 | + 'vue-style-loader', |
| 32 | + 'css-loader', |
| 33 | + 'sass-loader?indentedSyntax' |
| 34 | + ], |
| 35 | + }, |
| 36 | + { |
| 37 | + test: /\.vue$/, |
| 38 | + loader: 'vue-loader', |
| 39 | + options: { |
| 40 | + loaders: { |
| 41 | + // Since sass-loader (weirdly) has SCSS as its default parse mode, we map |
| 42 | + // the "scss" and "sass" values for the lang attribute to the right configs here. |
| 43 | + // other preprocessors should work out of the box, no loader config like this necessary. |
| 44 | + 'scss': [ |
| 45 | + 'vue-style-loader', |
| 46 | + 'css-loader', |
| 47 | + 'sass-loader' |
| 48 | + ], |
| 49 | + 'sass': [ |
| 50 | + 'vue-style-loader', |
| 51 | + 'css-loader', |
| 52 | + 'sass-loader?indentedSyntax' |
| 53 | + ] |
| 54 | + } |
| 55 | + // other vue-loader options go here |
| 56 | + } |
| 57 | + }, |
| 58 | + { |
| 59 | + test: /\.js$/, |
| 60 | + loader: 'babel-loader', |
| 61 | + exclude: /node_modules/ |
| 62 | + }, |
| 63 | + { |
| 64 | + test: /\.(png|jpg|gif|svg)$/, |
| 65 | + loader: 'file-loader', |
| 66 | + options: { |
| 67 | + name: '[name].[ext]?[hash]' |
| 68 | + } |
| 69 | + } |
| 70 | + ] |
| 71 | + }, |
| 72 | + resolve: { |
| 73 | + alias: { |
| 74 | + 'vue$': 'vue/dist/vue.esm.js' |
| 75 | + }, |
| 76 | + extensions: ['*', '.js', '.vue', '.json'] |
| 77 | + }, |
| 78 | + devServer: { |
| 79 | + historyApiFallback: true, |
| 80 | + noInfo: true, |
| 81 | + overlay: true |
| 82 | + }, |
| 83 | + performance: { |
| 84 | + hints: false |
| 85 | + }, |
| 86 | + devtool: '#eval-source-map' |
| 87 | +} |
| 88 | + |
| 89 | +if (process.env.NODE_ENV === 'production') { |
| 90 | + module.exports.devtool = '#source-map' |
| 91 | + // http://vue-loader.vuejs.org/en/workflow/production.html |
| 92 | + module.exports.plugins = (module.exports.plugins || []).concat([ |
| 93 | + new webpack.DefinePlugin({ |
| 94 | + 'process.env': { |
| 95 | + NODE_ENV: '"production"' |
| 96 | + } |
| 97 | + }), |
| 98 | + new webpack.optimize.UglifyJsPlugin({ |
| 99 | + sourceMap: true, |
| 100 | + compress: { |
| 101 | + warnings: false |
| 102 | + } |
| 103 | + }), |
| 104 | + new webpack.LoaderOptionsPlugin({ |
| 105 | + minimize: true |
| 106 | + }) |
| 107 | + ]) |
| 108 | +} |
0 commit comments