|
1 var path = require('path') |
|
2 var webpack = require('webpack') |
|
3 var ExtractTextPlugin = require("extract-text-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 resolveLoader: { |
|
13 root: path.join(__dirname, 'node_modules'), |
|
14 }, |
|
15 module: { |
|
16 plugins: [], |
|
17 loaders: [ |
|
18 { |
|
19 test: /\.vue$/, |
|
20 loader: 'vue' |
|
21 }, |
|
22 { |
|
23 test: /\.css$/, |
|
24 loader: ExtractTextPlugin.extract({ fallbackLoader: "style-loader", loader: "css-loader" }) |
|
25 }, |
|
26 { |
|
27 test: /\.js$/, |
|
28 loader: 'babel-loader', |
|
29 //exclude: /node_modules/, |
|
30 query: { |
|
31 presets: ['es2015'] |
|
32 }, |
|
33 "plugins": ["transform-es2015-shorthand-properties"] |
|
34 }, |
|
35 { |
|
36 test: /\.(png|jpg|gif|svg)$/, |
|
37 loader: 'file', |
|
38 query: { |
|
39 name: '[name].[ext]?[hash]' |
|
40 } |
|
41 }, |
|
42 { |
|
43 test: require.resolve('snapsvg'), |
|
44 loader: 'imports-loader?this=>window,fix=>module.exports=0' |
|
45 }, |
|
46 ] |
|
47 }, |
|
48 devServer: { |
|
49 historyApiFallback: true, |
|
50 noInfo: true |
|
51 }, |
|
52 devtool: '#eval-source-map' |
|
53 } |
|
54 |
|
55 if (process.env.NODE_ENV === 'production') { |
|
56 module.exports.devtool = '#source-map' |
|
57 // http://vue-loader.vuejs.org/en/workflow/production.html |
|
58 module.exports.plugins = (module.exports.plugins || []).concat([ |
|
59 new webpack.DefinePlugin({ |
|
60 'process.env': { |
|
61 NODE_ENV: '"production"' |
|
62 } |
|
63 }), |
|
64 new webpack.optimize.UglifyJsPlugin({ |
|
65 compress: { |
|
66 warnings: false |
|
67 } |
|
68 }), |
|
69 new webpack.optimize.OccurenceOrderPlugin() |
|
70 ]) |
|
71 } |