-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcreate-config.js
44 lines (40 loc) · 1.21 KB
/
create-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
function createEmberCLIConfig(forceEnabled = undefined, ownConfig = {}) {
const isEnabled = forceEnabled ?? !!process.env.ENABLE_BUNDLE_ANALYZER;
return isEnabled
? {
bundleAnalyzer: {
enabled: true,
...ownConfig,
},
fingerprint: {
enabled: false,
},
sourcemaps: { enabled: true, extensions: ['js', 'css'] },
autoImport: {
webpack: createWebpackConfig(isEnabled),
},
}
: {};
}
function createWebpackConfig(forceEnabled) {
const isEnabled = forceEnabled ?? !!process.env.ENABLE_BUNDLE_ANALYZER;
return isEnabled
? {
devtool: 'source-map',
optimization: {
chunkIds: 'named',
},
output: {
clean: true,
// Ideally we would tweak the webpack chunk names here like below, to give the user some more understandable names that just random IDs.
// But the problem is that ember-auto-import and Embroider don't allow for the same config to work for both.
// filename: 'assets/chunk.[id].js',
// chunkFilename: 'assets/chunk.[id].js',
},
}
: {};
}
module.exports = {
createEmberCLIConfig,
createWebpackConfig,
};