|
1 var path = require('path') |
|
2 var webpack = require('webpack') |
|
3 var ExtractTextPlugin = require("extract-text-webpack-plugin") |
|
4 var projectRoot = path.resolve(__dirname, 'src_js/iconolab-bundle') |
|
5 |
|
6 module.exports = { |
|
7 entry: { |
|
8 iconolab: [ |
|
9 './src_js/iconolab-bundle/src/main.js', |
|
10 './src_js/iconolab-bundle/src/main.scss', |
|
11 ] |
|
12 }, |
|
13 output: { |
|
14 path: __dirname + '/src/iconolab/static', |
|
15 publicPath: '/static/', |
|
16 filename: 'iconolab/js/[name].js' |
|
17 }, |
|
18 module: { |
|
19 loaders: [ |
|
20 { |
|
21 test: /\.vue$/, |
|
22 loader: 'vue' |
|
23 }, |
|
24 { |
|
25 test: /\.css$/, |
|
26 loader: ExtractTextPlugin.extract("style-loader", "css-loader?modules&localIdentName=[local]"), |
|
27 include: [ |
|
28 __dirname + '/src_js/iconolab-bundle/src', |
|
29 /node_modules/ |
|
30 ] |
|
31 }, |
|
32 { |
|
33 test: /\.scss$/, |
|
34 loader: ExtractTextPlugin.extract("style-loader", "css-loader?modules&importLoaders=1&localIdentName=[local]!resolve-url-loader!sass-loader"), |
|
35 include: [ |
|
36 __dirname + '/src_js/iconolab-bundle/src', |
|
37 /node_modules/ |
|
38 ] |
|
39 }, |
|
40 { |
|
41 test: /\.js$/, |
|
42 loader: 'babel-loader', |
|
43 exclude: /node_modules/, |
|
44 include: [ |
|
45 path.join(projectRoot, 'src') |
|
46 ], |
|
47 query: { |
|
48 presets: ['es2015'] |
|
49 }, |
|
50 "plugins": ["transform-es2015-shorthand-properties"] |
|
51 }, |
|
52 { |
|
53 test: /\.(png|jpg|gif|svg)$/, |
|
54 loader: 'file', |
|
55 query: { |
|
56 name: '[name].[ext]?[hash]' |
|
57 } |
|
58 }, |
|
59 { |
|
60 test: /\.(ttf|eot|svg|woff|woff2)(\?v=[0-9]\.[0-9]\.[0-9])?$/, |
|
61 loader: 'file-loader?name=iconolab/fonts/[name].[ext]' |
|
62 }, |
|
63 { |
|
64 test: require.resolve('snapsvg'), |
|
65 loader: 'imports-loader?this=>window,fix=>module.exports=0' |
|
66 }, |
|
67 ] |
|
68 }, |
|
69 plugins: [ |
|
70 new ExtractTextPlugin("iconolab/css/[name].css"), |
|
71 new webpack.ProvidePlugin({ |
|
72 $: "jquery", |
|
73 jQuery: "jquery" |
|
74 }) |
|
75 ], |
|
76 devServer: { |
|
77 port: 8001, |
|
78 contentBase: __dirname + '/src/iconolab', |
|
79 publicPath: '/static/', |
|
80 stats: 'minimal', |
|
81 compress: true, |
|
82 headers: { 'Access-Control-Allow-Origin': '*' }, |
|
83 historyApiFallback: true, |
|
84 }, |
|
85 devtool: '#source-map' |
|
86 } |
|
87 |
|
88 if (process.env.NODE_ENV === 'production') { |
|
89 module.exports.devtool = '#source-map' |
|
90 // http://vue-loader.vuejs.org/en/workflow/production.html |
|
91 module.exports.plugins = (module.exports.plugins || []).concat([ |
|
92 new webpack.DefinePlugin({ |
|
93 'process.env': { |
|
94 NODE_ENV: '"production"' |
|
95 } |
|
96 }), |
|
97 new webpack.optimize.UglifyJsPlugin({ |
|
98 compress: { |
|
99 warnings: false |
|
100 } |
|
101 }), |
|
102 new webpack.optimize.OccurenceOrderPlugin() |
|
103 ]) |
|
104 } |