This repository was archived by the owner on Aug 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.config.js
96 lines (89 loc) · 1.96 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
var path = require("path");
var webpack = require('webpack');
var BundleTracker = require('webpack-bundle-tracker');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
var fs = require("fs");
function getReactChunks(){
// Add all jsx files in ./frontend as entries
var files = fs.readdirSync('./frontend/').filter(function(f){
return f.endsWith('.jsx');
})
var entries = {};
files.forEach(function(f){
entries[f.replace(/.jsx/, '')] = ['./frontend/' + f];
});
return entries;
}
const reactBuild = {
name: 'react',
context: __dirname,
entry: getReactChunks(),
output: {
path: path.resolve('./static/dist/'),
filename: "[name]-[contenthash].js",
publicPath: "/static/dist/",
},
devtool: 'source-map',
module: {
rules: [
{
test: /\.woff2?$|\.ttf$|\.eot$|\.svg$|\.png$/,
use: [
{
loader: 'file-loader',
}
]
},
{
test: /\.scss$/,
use: [
{ loader: 'style-loader'},
{ loader: 'css-loader'},
{ loader: 'sass-loader'}
]
},
{
test: /\.css$/,
use: [
{ loader: 'style-loader'},
{ loader: 'css-loader'}
]
},
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
],
},
externals: {
jquery: 'jQuery',
$: 'jQuery'
},
optimization: {
//runtimeChunk: "single", // enable "runtime" chunk
splitChunks: {
cacheGroups: {
common: {
name: 'common',
chunks: 'initial',
minChunks: 3
}
}
}
},
plugins: [
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new BundleTracker(
{filename: './static/dist/webpack-manifest.json'}
),
],
resolve: {
modules: [
path.join(__dirname, "frontend"),
'node_modules',
],
extensions: ['.js', '.jsx', '.scss']
},
};
module.exports = reactBuild