-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcraco.config.js
41 lines (36 loc) · 1.13 KB
/
craco.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
const path = require('path');
module.exports = {
devServer: (devServerConfig, { env, paths, proxy, allowedHost }) => {
devServerConfig.devMiddleware.writeToDisk = true;
return devServerConfig;
},
webpack: {
configure: (webpackConfig, { paths }) => {
// Find instance of HTML Webpack plugin
const pluginInstance = webpackConfig.plugins.find(
plugin => plugin.constructor.name === 'HtmlWebpackPlugin'
);
if (pluginInstance) {
// Exclude content and background scripts from index.html
pluginInstance.userOptions.excludeChunks = ['content', 'background'];
}
return {
...webpackConfig,
entry: {
main: paths.appIndexJs,
content: './src/scripts/content/index.ts',
background: './src/scripts/background/index.ts'
},
output: {
...webpackConfig.output,
filename: ({ chunk }) => {
if (['content', 'background'].includes(chunk.name)) {
return 'static/js/[name].js';
}
return 'static/js/[name].[contenthash].js';
},
},
};
},
}
};