|
| 1 | +var path = require('path') |
| 2 | +var webpack = require('webpack') |
| 3 | +var BundleTracker = require('webpack-bundle-tracker') |
| 4 | + |
| 5 | +module.exports = { |
| 6 | + context: __dirname, |
| 7 | + entry: { |
| 8 | + sample: './src/sample/', |
| 9 | + }, |
| 10 | + output: { |
| 11 | + path: path.resolve('../pythonph/assets/webpack_bundles/'), |
| 12 | + publicPath: '/assets/webpack_bundles/', |
| 13 | + filename: '[name].[chunkhash].js' |
| 14 | + }, |
| 15 | + plugins: [ |
| 16 | + new BundleTracker({filename: './webpack-stats.json'}) |
| 17 | + ], |
| 18 | + module: { |
| 19 | + rules: [ |
| 20 | + { |
| 21 | + enforce: 'pre', |
| 22 | + test: /\.vue$/, |
| 23 | + exclude: /node_modules/, |
| 24 | + loader: 'eslint-loader', |
| 25 | + }, |
| 26 | + { |
| 27 | + test: /\.vue$/, |
| 28 | + loader: 'vue-loader', |
| 29 | + options: { |
| 30 | + loaders: { |
| 31 | + } |
| 32 | + // other vue-loader options go here |
| 33 | + } |
| 34 | + }, |
| 35 | + { |
| 36 | + test: /\.js$/, |
| 37 | + loader: 'babel-loader', |
| 38 | + exclude: /node_modules(?![\\/]vue-awesome[\\/])/ |
| 39 | + }, |
| 40 | + { |
| 41 | + test: /\.(png|jpg|gif|svg)$/, |
| 42 | + loader: 'file-loader', |
| 43 | + options: { |
| 44 | + name: '[name].[ext]?[hash]' |
| 45 | + } |
| 46 | + }, |
| 47 | + // For bootstrap-vue |
| 48 | + { |
| 49 | + test: /\.css$/, |
| 50 | + loaders: [ |
| 51 | + 'style-loader', |
| 52 | + 'css-loader' |
| 53 | + ] |
| 54 | + }, |
| 55 | + // https://gist.github.com/mosinve/00d1c2715dd573c6db38e9ac7139c215#file-webpack-config-js-L49 |
| 56 | + {test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader?mimetype=image/svg+xml'}, |
| 57 | + {test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader?mimetype=application/font-woff'}, |
| 58 | + {test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader?mimetype=application/font-woff'}, |
| 59 | + {test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader?mimetype=application/octet-stream'}, |
| 60 | + {test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader'}, |
| 61 | + ] |
| 62 | + }, |
| 63 | + resolve: { |
| 64 | + alias: { |
| 65 | + 'vue$': 'vue/dist/vue.esm.js', |
| 66 | + 'app': path.resolve('./src') |
| 67 | + } |
| 68 | + }, |
| 69 | + devServer: { |
| 70 | + historyApiFallback: true, |
| 71 | + noInfo: true, |
| 72 | + overlay: true |
| 73 | + }, |
| 74 | + performance: { |
| 75 | + hints: false |
| 76 | + }, |
| 77 | + devtool: '#eval-source-map' |
| 78 | +} |
| 79 | + |
| 80 | +if (process.env.NODE_ENV === 'production') { |
| 81 | + module.exports.devtool = '#source-map' |
| 82 | + // http://vue-loader.vuejs.org/en/workflow/production.html |
| 83 | + module.exports.plugins = (module.exports.plugins || []).concat([ |
| 84 | + new webpack.DefinePlugin({ |
| 85 | + 'process.env': { |
| 86 | + NODE_ENV: '"production"' |
| 87 | + } |
| 88 | + }), |
| 89 | + new webpack.optimize.UglifyJsPlugin({ |
| 90 | + sourceMap: true, |
| 91 | + compress: { |
| 92 | + warnings: false |
| 93 | + } |
| 94 | + }), |
| 95 | + new webpack.LoaderOptionsPlugin({ |
| 96 | + minimize: true |
| 97 | + }) |
| 98 | + ]) |
| 99 | +} |
0 commit comments