-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
63 lines (61 loc) · 1.91 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
58
59
60
61
62
63
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = function(options) {
var config = {
entry: [
'./www/src/app.js'
],
output: {
path: path.join(__dirname, 'www/build'),
filename: 'bundle.js',
publicPath: './build/'
},
module: {
loaders: [{
test: /\.js?$/,
loader: 'babel',
query: {
presets: ['react']
},
exclude: /node_modules/
},{
test: /\.less$/,
loader: ExtractTextPlugin.extract("style-loader", "css-loader!less-loader")
}, {
test: /\.(png|jpg)$/,
loader: 'url-loader?limit=8192'
}],
noParse: [/moment-with-locales/]
},
resolve: {
extensions: ['', '.js', '.jsx', '.json', '.coffee'],
alias: {
lib: path.join(__dirname, "./www/lib"),
view: path.join(__dirname, "./www/src/view"),
moment: "moment/min/moment-with-locales.min.js"
}
}
};
// 开发模式
if (options.environment === 'dev') {
config.devtool = 'source-map';
Array.prototype.unshift.call(
config.entry,
'webpack-dev-server/client?http://127.0.0.1:3000',
'webpack/hot/only-dev-server'
);
config.plugins = [
new ExtractTextPlugin("app.css"),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
];
config.output.publicPath = '/www/build/';
// config.module.loaders[0].loaders.unshift('react-hot');
} else {
config.plugins = [
new ExtractTextPlugin("app.css")
];
}
return config;
};