Skip to content

Instantly share code, notes, and snippets.

@vimcaw
Created May 16, 2020 02:59
Show Gist options
  • Save vimcaw/2056dbc92ec7a8cc8fdcec0c513ed45c to your computer and use it in GitHub Desktop.
Save vimcaw/2056dbc92ec7a8cc8fdcec0c513ed45c to your computer and use it in GitHub Desktop.
Using craco to override creat-react-app htmlWebpackPlugin options
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = () => {
return {
webpack: {
configure: (webpackConfig, { env }) => {
if (env !== 'development') {
const htmlWebpackPluginInstance = webpackConfig.plugins.find(
webpackPlugin => webpackPlugin instanceof HtmlWebpackPlugin
);
if (htmlWebpackPluginInstance) {
htmlWebpackPluginInstance.options.inject = false;
}
}
return webpackConfig;
},
},
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment