-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathwebpack.config.js
76 lines (73 loc) · 1.7 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
const path = require('path');
const webpack = require('webpack');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const config = {
context: __dirname,
entry: [
'react-hot-loader/patch',
'./js/app.js',
'./js/ClientApp.jsx'
],
devtool:
process.env.NODE_ENV === "development" ? "cheap-eval-source-map" : false,
output: {
path: path.join(__dirname, 'public'),
filename: 'bundle.js',
publicPath: '/public/'
},
devServer: {
hot: true,
publicPath: '/public/',
historyApiFallback: true
},
resolve: {
extensions: ['.js', '.jsx', '.json', 'css']
// alias: {
// react: 'preact-compat',
// 'react-dom': 'preact-compat',
// },
},
stats: {
colors: true,
reasons: true,
chunks: true
},
plugins: [
new UglifyJSPlugin({ sourceMap: true }),
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(),
new ExtractTextPlugin('styles.css')
],
module: {
rules: [
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
use: [
{ loader: 'css-loader', options: { importLoaders: 1 } },
'postcss-loader'
],
fallback: 'style-loader'
})
},
{
enforce: 'pre',
test: /\.jsx?$/,
loader: 'eslint-loader',
exclude: /node_modules/
},
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/
}
]
}
};
if (process.env.NODE_ENV === "development") {
config.entry.unshift(
"webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000"
);
}
module.exports = config;