-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig-overrides.js
37 lines (34 loc) · 1.18 KB
/
config-overrides.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
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlInlineCssWebpackPlugin =
require('html-inline-css-webpack-plugin').default;
const HtmlInlineScriptPlugin = require('html-inline-script-webpack-plugin');
module.exports = {
webpack: function (config, env) {
//inline css and scripts right after chunk plugin.
//chunk plugin will not be present for development build and thats ok.
const inlineChunkHtmlPlugin = config.plugins.find(
(element) => element.constructor.name === 'InlineChunkHtmlPlugin',
);
if (inlineChunkHtmlPlugin) {
config.plugins.splice(
config.plugins.indexOf(inlineChunkHtmlPlugin),
0,
new HtmlInlineCssWebpackPlugin(),
new HtmlInlineScriptPlugin(),
);
}
//Override HtmlWebpack plugin with preserving all options and modifying what we want
const htmlWebpackPlugin = config.plugins.find(
(element) => element.constructor.name === 'HtmlWebpackPlugin',
);
config.plugins.splice(
config.plugins.indexOf(htmlWebpackPlugin),
1,
new HtmlWebpackPlugin({
...htmlWebpackPlugin.userOptions,
inject: 'body',
}),
);
return config;
},
};