forked from vintasoftware/django-react-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.local.config.js
73 lines (63 loc) · 1.74 KB
/
webpack.local.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
const autoprefixer = require('autoprefixer');
const webpack = require('webpack');
const BundleTracker = require('webpack-bundle-tracker');
const CircularDependencyPlugin = require('circular-dependency-plugin');
const path = require('path');
const baseConfig = require('./webpack.base.config');
const nodeModulesDir = path.resolve(__dirname, 'node_modules');
baseConfig.mode = 'development';
baseConfig.entry = [
'react-hot-loader/patch',
'whatwg-fetch',
'@babel/polyfill',
'./frontend/js/index.js',
];
baseConfig.optimization = {
splitChunks: {
chunks: 'all',
},
};
baseConfig.output = {
path: path.resolve('./frontend/bundles/'),
publicPath: 'http://localhost:3000/frontend/bundles/',
filename: '[name].js',
};
baseConfig.module.rules.push(
{
test: /\.jsx?$/,
exclude: [nodeModulesDir],
loader: require.resolve('babel-loader'),
},
{
test: /\.(woff(2)?|eot|ttf)(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader?limit=100000',
}
);
baseConfig.plugins = [
new webpack.EvalSourceMapDevToolPlugin({
exclude: /node_modules/
}),
new webpack.NamedModulesPlugin(),
new webpack.NoEmitOnErrorsPlugin(), // don't reload if there is an error
new BundleTracker({
filename: './webpack-stats.json',
}),
new webpack.LoaderOptionsPlugin({
options: {
context: __dirname,
postcss: [autoprefixer],
},
}),
new CircularDependencyPlugin({
// exclude detection of files based on a RegExp
exclude: /a\.js|node_modules/,
// add errors to webpack instead of warnings
failOnError: true,
// set the current working directory for displaying module paths
cwd: process.cwd(),
}),
];
baseConfig.resolve.alias = {
'react-dom': '@hot-loader/react-dom',
};
module.exports = baseConfig;