question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using babel enviroment variables

See original GitHub issue

I am looking to implement babel-plugin-react-remove-properties but the CRACO config file only seems to mention added babel plugins directly into the babel plugin array. Doesnt seem to add plugins depending on the environment.

The plugin installation shows applying only to production as so:

{
  "env": {
    "production": {
      "plugins": [
        "react-remove-properties"
      ]
    }
  }
}

Is this possible with CRACO?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:5

github_iconTop GitHub Comments

6reactions
robmarshallcommented, Nov 2, 2020
const { whenProd } = require('@craco/craco');

module.exports = {
    babel: {
        plugins: [
            ...whenProd(
                () => [
                    [
                        'react-remove-properties',
                        {
                            properties: ['data-testid']
                        }
                    ]
                ],
                []
            )
        ]
    }
};

1reaction
robmarshallcommented, Aug 17, 2020

Anyone able to point me in the right direction? Or where to go to find this out?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Environment variables and Babel | harrytheo.com
Configure env variables with Babel# · Install the plugin with npm install babel-plugin-inline-dotenv · Include the plugin and the path to the .env ......
Read more >
Environment variables and Babel | by Harry Theo | Geek Culture
In this short guide we will look at a simple way of configuring our environment variables and load them for use inside of...
Read more >
babel-plugin-transform-inline-environment-variables
With a configuration file (Recommended) · Via CLI · Via Node API.
Read more >
environment variables in babel.config.js - Stack Overflow
To access your env variables within the babel.config.js file, use the dotenv package like this: require('dotenv').config ...
Read more >
babel-plugin-transform-inline-environment-variables - npm
Start using babel-plugin-transform-inline-environment-variables in your project ... There are 197 other projects in the npm registry using ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found