-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrazzle.config.js
59 lines (50 loc) · 1.7 KB
/
razzle.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
const { modifyRule } = require('razzle-config-utils');
const webpack = require('webpack'); // eslint-disable-line import/no-extraneous-dependencies
module.exports = {
plugins: [],
modifyWebpackConfig({ env: { target, dev }, webpackConfig: appConfig }) {
// Razzle/CRA breaks the build on webpack warnings. Disable CI env to circumvent the check.
process.env.CI = 'false';
const addEntry = options => {
if (target === 'web') {
if (dev) {
appConfig.entry[options.name] = [
appConfig.entry.client[0], // hot reloading
options.entry,
];
} else {
appConfig.entry[options.name] = [options.entry];
}
}
};
modifyRule(appConfig, { test: /\.css$/ }, rule => {
rule.use.push({ loader: 'postcss-loader' });
});
addEntry({ entry: './src/polyfill', name: 'polyfill' });
if (target === 'web') {
appConfig.output.filename = dev
? 'static/js/[name].js'
: 'static/js/[name].[hash:8].js';
if (!dev) {
appConfig.optimization.concatenateModules = true;
} else {
appConfig.entry.injectCss = ['./src/style/index.css'];
}
appConfig.performance = {
hints: false,
};
}
if (target === 'node' && !dev) {
// This change bundles node_modules into server.js. The result is smaller Docker images.
// It triggers a couple of «Critical dependency: the request of a dependency is an
// expression warning» which we can safely ignore.
appConfig.externals = [];
}
if (!dev) {
appConfig.devtool = 'source-map';
} else {
appConfig.devtool = 'cheap-module-source-map';
}
return appConfig;
},
};