Comments (3)
Which framework are you using?
If it depends on react-app-rewired, it's quite likely that the config-overrides.js
file it uses is the same one that react-app-rewired uses - i.e. the framework is likely to be passing the config-overrides.js
file to react-app-rewired.
from react-app-rewired.
The framework we use is private sdk which is not public open source codes. It's very modified file from original config-overrides.js
file.
from react-app-rewired.
Yes, you can create your own config-overrides.js in the root of your project and use it to extend or override the existing config-overrides.js provided by the framework SDK. However, you will need to ensure that your custom configuration properly integrates or merges with the existing one to avoid any conflicts or issues.
Here's how you can achieve this:
Install Necessary Packages: Ensure you have react-app-rewired installed. You can install it using npm or yarn if it's not already installed:
bash
npm install react-app-rewired --save-dev
or
bash
yarn add react-app-rewired --dev
Create Your Custom config-overrides.js: In the root directory of your project, create a new config-overrides.js file.
Merge or Extend the Existing Configuration: Inside your config-overrides.js, you will import the existing configuration from the framework SDK and then extend or modify it as needed.
Here is an example of how you can do this:
javascript
// config-overrides.js in the root of your project
const { override, addBabelPlugins, addWebpackAlias } = require('customize-cra');
const path = require('path');
// Import the existing config-overrides.js from the framework SDK
const frameworkOverrides = require('framework-sdk/path/to/config-overrides.js'); // Adjust the path accordingly
// Function to merge/override configurations
const myOverrides = (config, env) => {
// Apply the framework's overrides first
config = frameworkOverrides(config, env);
// Now apply your custom overrides
return override(
// Example: Add Babel plugins
...addBabelPlugins(
'babel-plugin-styled-components',
'@babel/plugin-proposal-optional-chaining'
),
// Example: Add Webpack alias
addWebpackAlias({
'@components': path.resolve(__dirname, 'src/components')
})
)(config, env);
};
module.exports = myOverrides;
In the example above:
We first apply the framework's config-overrides.js to the configuration.
Then, we use customize-cra (a popular library for customizing Create React App configurations) to add our own custom overrides, such as Babel plugins and Webpack aliases.
Update Your package.json Scripts: Ensure your package.json scripts are set up to use react-app-rewired instead of react-scripts. For example:
json
{
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-scripts eject"
}
}
By following these steps, you can effectively extend or override the existing config-overrides.js provided by the framework SDK with your own custom configurations.
from react-app-rewired.
Related Issues (20)
- Combine react-rewired start command with sst start command?
- How to return multiple webpack configurations properly? HOT 1
- Trouble to start the dev server HOT 2
- react-scripts replace to react-app-rewired, but TS error is not presented
- Getting CRA error when trying to run jest test runner after installing recat-app-rewired
- how to ignore less file's image url path HOT 1
- How to modify css-loader options?
- Getting error when integrating module federation Plugin
- Override webpackEnv used in CRA config
- Error Running react-app-rewired build && compress-cra on Amazon Linux
- Build Failed using react-app-rewired HOT 3
- why could not found the module when using custom path
- when I run npm start I got some error its existing project i want to run in my system HOT 4
- Problem Reload Page
- How to debug react app in VSCode HOT 1
- Stuck on Creating an optimized production build... HOT 3
- scss solution HOT 1
- hardcoded NODE_ENV production? HOT 2
- npm run build doesn't exit after successful completion HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-app-rewired.