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