Created
March 15, 2021 21:18
-
-
Save justsml/1f13cd0d49c0d75aa0bebc3d5d4d7e43 to your computer and use it in GitHub Desktop.
Reference for 'Rewiring' Create-React-Apps without their rude defaults.
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
// Follow setup instructions https://github.com/timarney/react-app-rewired | |
// Example config: | |
const path = require('path'); | |
const { alias, configPaths } = require('react-app-rewire-alias'); | |
const addRewireScssLoader = require('react-app-rewire-scss-loaders'); | |
const rewireWebpackBundleAnalyzer = require('react-app-rewire-webpack-bundle-analyzer'); | |
module.exports = function override(config, env) { | |
// Fucking CRApps feel entitled to overwrite tsconfig.json... | |
alias(configPaths('./tsconfig.paths.json'))(config); | |
// Customize SASS | |
config = addRewireScssLoader('sass-resources-loader', { | |
resources: [path.resolve(__dirname, 'src/theme', '_variables.scss')], | |
})(config, env); | |
// Add bundle analyzer visualization | |
if (env !== 'development') { | |
config = rewireWebpackBundleAnalyzer(config, env, { | |
analyzerMode: 'static', | |
reportFilename: 'build/report.html', | |
}); | |
} | |
return config; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment