forked from themexpert/onepager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
54 lines (48 loc) · 1.45 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
var path = require('path');
var merge = require('webpack-merge');
var webpack = require('webpack');
var TARGET = process.env.TARGET;
var ROOT_PATH = path.resolve(__dirname);
var isProduction = process.argv.indexOf('-p') !== -1;
var common = {
entry: {
optionspanel: ['./engine/optionspanel.jsx'],
'onepager-builder': ['./engine/onepager-builder.jsx'],
'onepager-preview': ['./engine/onepager-preview.jsx'],
generator: ['./engine/generator.jsx']
},
output: {
filename: '[name].bundle.js',
path: __dirname + '/assets'
},
module: {
loaders: [
// The module to load. "babel" is short for "babel-loader"
{test: /\.jsx?$/, loaders: ['babel?stage=1'], include: path.resolve(ROOT_PATH, 'engine')},
// use ! to chain loaders
{test: /\.css$/, loader: 'style!css'},
{test: /\.less$/, loader: 'style!css!less'},
// inline base64 URLs for <=8k images, direct URLs for the rest
{test: /\.(png|jpg)$/, loader: 'url?limit=10240'}
]
}
};
if(isProduction){
common.module.loaders.push({ test: /\.jsx?$/, loader: "strip-loader?strip[]=console.log" });
common.plugins = [
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.DefinePlugin({
'process.env': {
// This has effect on the react lib size
'NODE_ENV': JSON.stringify('production'),
}
}),
new webpack.NoErrorsPlugin()
];
}
module.exports = merge(common, {
});