-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcraco.config.js
50 lines (47 loc) · 1.56 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
42
43
44
45
46
47
48
49
50
module.exports = {
webpack: {
configure: (webpackConfig, { env, paths }) => {
paths.appBuild = webpackConfig.output.filename = "genome-browser.js";
const styleLoaderConfig = {
loader: 'style-loader',
options: {
injectType: 'singletonStyleTag',
insert: function insertAtTop(element) {
window.setTimeout(function() {
var instance = document.querySelector('rnacentral-genome-browser');
instance.shadowRoot.appendChild(element);
});
},
},
};
for (const rule of webpackConfig.module.rules) {
if (rule.oneOf && Array.isArray(rule.oneOf)) {
for (const subRule of rule.oneOf) {
const pattern = (subRule.test || '').toString();
if (
[
/\.css$/.toString(),
/\.(scss|sass)$/.toString(),
/\.module\.css$/.toString(),
/\.module\.(scss|sass)$/.toString(),
].includes(pattern)
) {
subRule.use = subRule.use.filter(item => {
if (typeof item === 'string') {
// Dev Mode
return !item.includes('style-loader');
} else if (item.loader) {
// Build Mode
return !item.loader.includes('mini-css-extract-plugin');
}
return true;
});
subRule.use.unshift(styleLoaderConfig);
}
}
}
}
return webpackConfig;
},
},
};