Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

babel-plugin-transform-require-ignore

0.1.1 • Public • Published

babel-plugin-transform-require-ignore

Build Status NPM Dependencies License

Since https://nodejs.org/api/globals.html#globals_require_extensions deprecated.

We have to find another way to ignore the extensions for webpack usage and make it work in node environment.

Configure it in .babelrc for node, we could ignore the requirement when run test in node or build server render app.

Then we run babel with BABEL_ENV=node will active this plugin;

{
  "env": {
    "node": {
      "plugins": [
        [
          "babel-plugin-transform-require-ignore",
          {
            "extensions": [".less", ".sass"]
          }
        ]
      ]
    }
  }
}
 

or use with babel-register in require-hooks

require('babel-register')({
  'plugins': [
    [
      'babel-plugin-transform-require-ignore',
      {
        extensions: ['.scss']
      }
    ]
  ]
});

Or with cli like other plugin used.

Notice:

Only ignore import './some.less'; or require('./some.less');

If assign to some variable, means that may use css-module, please use https://github.com/css-modules/css-modules-require-hook instead.

Keywords

install

npm i babel-plugin-transform-require-ignore

Downloadsweekly downloads

4,038

version

0.1.1

license

MIT

repository

githubgithub

last publish

collaborators

  • avatar