Skip to content

Instantly share code, notes, and snippets.

@paveltretyakovru
Last active June 26, 2021 16:36
Show Gist options
  • Save paveltretyakovru/940da713ba718e58aecfc2868060f6ed to your computer and use it in GitHub Desktop.
Save paveltretyakovru/940da713ba718e58aecfc2868060f6ed to your computer and use it in GitHub Desktop.
To move CRA application to other directory than src (for example to src/frontend folder)
const path = require('path');
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
module.exports = {
paths: function (paths, env) {
paths.appIndexJs = path.resolve(__dirname, 'src/frontend/index.js');
paths.appSrc = path.resolve(__dirname, 'src/frontend');
return paths;
},
override(config, env) {
config.resolve.plugins = config.resolve.plugins.filter(
plugin => !(plugin instanceof ModuleScopePlugin)
);
return config;
}
}
yarn add --dev customize-cra react-app-rewired
{
// ...
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-app-rewired eject"
},
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment