-
Notifications
You must be signed in to change notification settings - Fork 4
/
extra-webpack.config.js
54 lines (48 loc) · 2.11 KB
/
extra-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
const singleSpaAngularWebpack = require('single-spa-angular/lib/webpack').default
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const ReplaceInFileWebpackPlugin = require('replace-in-file-webpack-plugin');
module.exports = (angularWebpackConfig, options) => {
const singleSpaWebpackConfig = singleSpaAngularWebpack(angularWebpackConfig, options)
singleSpaWebpackConfig.externals['@openmrs/esm-api'] = '@openmrs/esm-api';
singleSpaWebpackConfig.plugins.push(new BundleAnalyzerPlugin());
// console.log('webpack', singleSpaWebpackConfig);
if (singleSpaWebpackConfig.mode === 'production') {
const path = singleSpaWebpackConfig.output.path;
const publicPath = singleSpaWebpackConfig.output.publicPath;
console.log('path', path);
console.log('publicPath', publicPath);
// HACK to fix the deployment of fonts for bootstrap
// NOTE: this does not work with ng server --prod true, because the file does not exist
singleSpaWebpackConfig.plugins.push(
new ReplaceInFileWebpackPlugin([{
dir: path,
files: ['main-es2015.js'],
rules: [
{
search: 'glyphicons-halflings-regular.eot',
replace: publicPath + 'glyphicons-halflings-regular.eot'
},
{
search: 'glyphicons-halflings-regular.woff',
replace: publicPath + 'glyphicons-halflings-regular.woff'
},
// {
// search: 'glyphicons-halflings-regular.woff2',
// replace: publicPath + 'glyphicons-halflings-regular.woff2'
// },
{
search: 'glyphicons-halflings-regular.ttf',
replace: publicPath + 'glyphicons-halflings-regular.ttf'
},
{
search: 'glyphicons-halflings-regular.svg',
replace: publicPath + 'glyphicons-halflings-regular.svg'
}
]
}]
));
}
// singleSpaWebpackConfig.module.rules.push({parser: {system: false}})
// Feel free to modify this webpack config however you'd like to
return singleSpaWebpackConfig
}