-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
113 lines (107 loc) · 3.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
global.Promise = require('bluebird');
const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const productionBuild = process.env.NODE_ENV === 'production';
const nodeEnv = productionBuild ? 'production' : 'development';
const sourcePath = path.resolve(__dirname, 'src', 'App');
const publicPath = 'http://localhost:8050/public/assets';
const cssName = productionBuild ? 'styles-[hash].css' : 'styles.css';
const jsName = productionBuild ? 'bundle-[hash].js' : 'bundle.js';
const plugins = [
new webpack.DefinePlugin({
'process.env': {
BROWSER : JSON.stringify(true),
NODE_ENV: JSON.stringify(nodeEnv),
},
}),
new ExtractTextPlugin(cssName),
new webpack.LoaderOptionsPlugin({
options: {
context: __dirname,
},
}),
];
if (productionBuild) {
plugins.push(new webpack.optimize.DedupePlugin());
plugins.push(new webpack.optimize.OccurenceOrderPlugin());
} else {
plugins.push(new webpack.HotModuleReplacementPlugin());
}
module.exports = {
devtool: productionBuild ? 'source-map' : 'eval',
context: sourcePath,
entry : '../client.jsx',
plugins,
output: {
path : `${__dirname}/public/assets/`,
filename: jsName,
publicPath,
},
resolve: {
extensions: ['.webpack-loader.js', '.web-loader.js', '.loader.js', '.js', '.jsx'],
modules : [path.resolve(__dirname, 'src', 'modules'), 'node_modules'],
alias: {
'~': path.resolve(__dirname, 'src', 'App'),
react: path.resolve('./node_modules/react'),
'react-dom': path.resolve('./node_modules/react-dom'),
},
},
module: {
rules: [
{
test : /\.(js|jsx)$/,
exclude: [/node_modules/],
use : {
loader : 'babel-loader',
options: {
plugins: [
'transform-decorators-legacy',
'react-css-modules',
],
},
}
},
{
test : /\.css$/,
exclude: /node_modules/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use : [{
loader : 'css-loader',
options: {
modules: true,
importLoaders: 1,
localIdentName: '[path]___[name]__[local]___[hash:base64:5]'
}
},
{ loader: 'postcss-loader' }]
})
},
{ test: /\.(jpg|gif|png|woff|woff2|eot|ttf|svg)$/, use: 'url-loader?limit=100000' },
],
},
devServer: {
headers : { 'Access-Control-Allow-Origin': '*' },
contentBase : './client',
historyApiFallback: true,
port : 3001,
compress : productionBuild,
inline : !productionBuild,
hot : !productionBuild,
stats : {
assets : true,
children : false,
chunks : false,
hash : false,
modules : false,
publicPath: false,
timings : true,
version : false,
warnings : true,
colors : {
green: '\u001b[32m',
},
},
},
};