-
Notifications
You must be signed in to change notification settings - Fork 0
/
config-overrides.js
38 lines (34 loc) · 1.72 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
38
// https://github.com/timarney/react-app-rewired --> avoid ejecting and build inlining css and js in html
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 that's 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',
// // Add coffeescript to the template parameters
// templateParameters: {
// ...htmlWebpackPlugin.options.templateParameters,
// // Add the path to the main.js file in the public directory
// staticMainJS: './public/coffee-main.js',
// },
}
)
);
return config;
}
}