Skip to content

Instantly share code, notes, and snippets.

@justsml
Created March 15, 2021 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justsml/1f13cd0d49c0d75aa0bebc3d5d4d7e43 to your computer and use it in GitHub Desktop.
Save justsml/1f13cd0d49c0d75aa0bebc3d5d4d7e43 to your computer and use it in GitHub Desktop.
Reference for 'Rewiring' Create-React-Apps without their rude defaults.
// 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