This repository has been archived by the owner on Jan 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
webpack.config.js
112 lines (106 loc) · 2.71 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// @flow
/* eslint camelcase: 0 */
const path = require('path');
const webpack = require('webpack');
const node_env = (process.env.NODE_ENV || 'development').trim();
const HtmlWebpackPlugin = require('html-webpack-plugin');
const DashboardPlugin = require('webpack-dashboard/plugin');
let plugins = [
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
'process.env': {
BLUEBIRD_LONG_STACK_TRACES: JSON.stringify(false),
NODE_ENV: JSON.stringify(node_env),
},
IS_PRODUCTION: JSON.stringify(node_env === 'production'),
}),
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'src/index.html',
minify: {},
chunks: ['Common'],
}),
new HtmlWebpackPlugin({
filename: 'clean/index.html',
template: 'src/Clean/index.html',
minify: {},
chunks: ['Clean'],
}),
new DashboardPlugin(),
];
let jsLoader = 'babel!eslint';
if (node_env === 'production') {
plugins = plugins.concat([
new webpack.optimize.OccurenceOrderPlugin(true),
new webpack.optimize.UglifyJsPlugin(),
]);
jsLoader = 'babel';
}
const webpackConfig = {
eslint: {
configFile: '.eslintrc',
failOnWarning: false,
failOnError: true,
},
context: __dirname,
resolve: {
extensions: ['', '.js', '.jsx', '.json'],
root: path.resolve('src'),
alias: {
bluebird: 'bluebird/js/release/bluebird.js',
eventemitter: 'eventemitter3',
},
},
entry: {
Common: path.resolve('src/entry.js'),
Clean: path.resolve('src/Clean/entry.js'),
},
output: {
path: path.resolve('www'),
filename: '[name]-[hash].js',
chunkFilename: '[id]-[chunkhash].js',
publicPath: '/',
},
module: {
loaders: [
{ test: /^((?!CSS\.js$).)*(\.jsx?)$/,
exclude: /(node_modules)/,
include: /src/,
loader: jsLoader,
},
{ test: /\.css$/, loader: 'style!css' },
{ test: /\.CSS.js$/, exclude: /(node_modules)/, loader: 'inline-css!babel' },
{ test: /\.(jpg|png|gif|jpeg|ico)$/, loader: 'url?limit=10000' },
{ test: /\.woff2?(\?.*)?$/, loader: 'file' },
{ test: /\.(eot|ttf|otf|svg)(\?.*)?$/, loader: 'file' },
{ test: /\.json$/, loader: 'json' },
],
noParse: [
/primusClient\.js/,
],
},
plugins,
devServer: {
proxy: {
'/api/*': {
target: 'http://localhost:9500/',
changeOrigin: true,
xfwd: true,
ws: true,
secure: false,
},
'/primus/*': {
target: 'http://localhost:9500/',
changeOrigin: true,
xfwd: true,
ws: true,
secure: false,
},
},
},
};
if (node_env !== 'production') {
// $FlowFixMe
webpackConfig.devtool = 'cheap-module-source-map';
}
module.exports = webpackConfig;