Created
May 1, 2020 06:51
-
-
Save dimaqq/fc018fe043a4b70c395e74f6530829d5 to your computer and use it in GitHub Desktop.
This file contains 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 path = require("path"); | |
const immer = require("immer"); | |
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin; | |
const stats = process.argv.includes("--stats"); | |
module.exports = (config, env) => immer.produce(config, draft => { | |
// I just happen to know these indices: | |
// https://github.com/facebook/create-react-app/issues/7581#issuecomment-535305630 | |
draft.module.rules[2].oneOf[0].test.push(/[.]svg$/); | |
// Ad-hoc UseBabelRc() | |
// TODO not sure about configFile and presets: | |
// https://github.com/facebook/create-react-app/blob/a2ae8a79c0f6c0d07c6c2f1155d63f10efce9089/packages/react-scripts/config/webpack.config.js#L361 | |
draft.module.rules[2].oneOf[1].options.babelrc = true; | |
// Remove workbox plugin | |
draft.plugins = draft.plugins.filter( | |
plugin => !plugin || !plugin.config || !plugin.config.importWorkboxFrom); | |
// Remove asset-manifest.json | |
draft.plugins = draft.plugins.filter( | |
plugin => !plugin || !plugin.opts || plugin.opts.fileName !== "asset-manifest.json"); | |
if (stats) draft.plugins.push(new BundleAnalyzerPlugin()); | |
draft.resolve.alias.dev = path.join(__dirname, "../src/dev/", env); | |
console.log(JSON.stringify(draft, null, 2)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment