-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
57 lines (49 loc) · 1.43 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
55
56
57
var webpack = require('webpack');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var loaders = ['react-hot', 'jsx?harmony'];
var entry = [
'webpack-dev-server/client?http://0.0.0.0:3000', // WebpackDevServer host and port
'webpack/hot/only-dev-server',
__dirname + '/src/main.jsx'
];
var plugins = [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
];
var less = {
test:/\.less$/,
loader:"style-loader!css-loader!less-loader"
};
if(process.argv.length > 2 && process.argv[2] == 'deploy'){
loaders.shift();
entry.shift();
entry.shift();
less.loader = ExtractTextPlugin.extract("style-loader", "css-loader!less-loader");
plugins = [new ExtractTextPlugin("bundle.css"),
new webpack.optimize.UglifyJsPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
})
];
}
module.exports = {
// context: __dirname + '/src',
devtools: 'eval',
entry: entry,
output: {
path: __dirname + '/build',
filename:'bundle.js',
publicPath:'/build/'
},
module: {
loaders: [
{test:/\.jsx$/, loaders:loaders},
{test:/\.css$/,loader:"style-loader!css-loader"},
less
]
},
plugins: plugins
};