how to access custom variables ( defined in .env ) in craco.config.js ?
See original GitHub issueI want to change the @antd-prefix in CracoAntDesignPlugin, like below:
/* craco.config.js */
module.exports = function () {
console.log('env....', process.env.REACT_APP_ANTD_PREFIX);
return {
eslint: {
enable: true,
mode: 'file',
},
plugins: [
{
plugin: CracoAntDesignPlugin,
options: {
customizeTheme: {
'@ant-prefix': process.env.REACT_APP_ANTD_PREFIX,
},
customizeThemeLessPath: path.join(
__dirname,
'src/styles/antd.theme.less'
),
},
},
REACT_APP_ANTD_PREFIX is already defined in .env, but I got undefined
here. Is there any way to get the right result ?
Issue Analytics
- State:
- Created 3 years ago
- Comments:10
Top Results From Across the Web
how to access custom variables ( defined in .env ) in craco ...
I want to change the @antd-prefix in CracoAntDesignPlugin, like below: /* craco.config.js */ module.exports = function () { console.log('env ...
Read more >My Awesome Custom React Environment Variables Setup
Step 1 ~ Install install craco. ... Step 2 ~ Add a craco.config.js file to our folder structure. ... Below is our craco.config.js...
Read more >Adding Custom Environment Variables | Create React App
Your project can consume variables declared in your environment as if they were declared locally in your JS files.
Read more >npm:craco-plugin-env - Skypack.dev
First, follow the craco Installation Instructions to install the craco package, create a craco.config.js file, and modify the scripts in ...
Read more >How to use Environment files (.env) in React App - LinkedIn
2- Make a file called .env.envName in your project root, sush as .env.staging, .env.production, ... to differentiate between variables in each ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Try: Install
dotenv
then addrequire('dotenv/config')
at the top of your craco.config.jsIf you use CRA, you can just import the react script that loads the env files.
After this line in your craco.config.js file:
you will able to access the env vars defined in your env files.