forked from ChrisMLee/react-flux-cart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
executable file
·98 lines (92 loc) · 2.07 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var webpack = require('webpack');
var merge = require('webpack-merge');
var TARGET = process.env.TARGET;
var ROOT_PATH = path.resolve(__dirname);
var common = {
entry: [path.join(ROOT_PATH, 'app/main.jsx')],
resolve: {
extensions: ['', '.js', '.jsx'],
},
output: {
path: path.resolve(ROOT_PATH, 'build'),
filename: 'bundle.js',
},
module: {
loaders: [
{
test: /\.css$/,
loaders: ['style', 'css'],
},
],
},
};
var mergeConfig = merge.bind(null, common);
if(TARGET === 'build') {
module.exports = mergeConfig({
module: {
loaders: [
{
test: /\.jsx?$/,
loader: 'babel?optional[]=runtime&stage=1',
include: path.join(ROOT_PATH, 'app'),
},
],
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
// This has effect on the react lib size
'NODE_ENV': JSON.stringify('production'),
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
},
}),
new HtmlWebpackPlugin({
title: 'FluxCart ES6',
}),
],
});
}
if(TARGET === 'dev') {
var IP = '0.0.0.0';
var PORT = 8080;
module.exports = mergeConfig({
ip: IP,
port: PORT,
entry: [
'webpack-dev-server/client?http://' + IP + ':' + PORT,
'webpack/hot/only-dev-server',
],
module: {
preLoaders: [
{
test: /\.jsx?$/,
loader: 'eslint-loader',
include: path.join(ROOT_PATH, 'app'),
},
],
loaders: [
{
test: /\.jsx?$/,
loaders: ['react-hot', 'babel?optional[]=runtime&stage=1', 'flowcheck'],
include: path.join(ROOT_PATH, 'app'),
},
],
},
output: {
path: __dirname,
filename: 'bundle.js',
publicPath: '/',
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new HtmlWebpackPlugin(),
],
});
}