Created
May 16, 2020 02:59
-
-
Save vimcaw/2056dbc92ec7a8cc8fdcec0c513ed45c to your computer and use it in GitHub Desktop.
Using craco to override creat-react-app htmlWebpackPlugin options
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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