craco-babel-loader
Rewire `babel-loader` loader in your `create-react-app` project using `craco`.
Last updated 2 years ago by rjerue .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install craco-babel-loader 
SYNC missed versions from official npm registry.

This is a port of react-app-rewire-babel-loader to CRACO instead of react-app-rewired. react-app-rewired was not being updated for version 2 of CRA, and I wanted to use the rewired babel loader with a solution designed for CRA 2.

Rewire babel-loader loader in your create-react-app project using CRACO.

Say there is an awesome library you found on npm that you want to use within your un-ejected create-react-app project, but unfortunately, it's published in ES6+ (since node_modules doesn't go through babel-loader), so you cannot really use it. It's also effective for working with monorepos which was my original use case.

However, with CRACO and this library, craco-babel-loader, you can use that awesome library you've found.

See below for usage.

Install

$ yarn add craco-babel-loader
# npm v5+
$ npm install craco-babel-loader
# before npm v5
$ npm install --save craco-babel-loader

Usage

// crago.config.js
// see: https://github.com/sharegate/craco

const path = require("path");
const fs = require("fs");

const rewireBabelLoader = require("craco-babel-loader");

// helpers

const appDirectory = fs.realpathSync(process.cwd());
const resolveApp = relativePath => path.resolve(appDirectory, relativePath);

module.exports = {
  plugins: [
        //This is a craco plugin: https://github.com/sharegate/craco/blob/master/packages/craco/README.md#configuration-overview
        { plugin: rewireBabelLoader, 
          options: { 
            includes: [resolveApp("node_modules/isemail")], //put things you want to include in array here
            excludes: [/(node_modules|bower_components)/] //things you want to exclude here
            //you can omit include or exclude if you only want to use one option
          }
        }
    ]
}

Development

Chores

  • Lint: yarn run lint
  • Prettier: yarn run pretty
  • Test: yarn run test
  • Pre-publish: yarn run prepublish
  • Build: yarn run build

License

MIT.

Current Tags

  • 1.0.4                                ...           latest (2 years ago)

8 Versions

  • 1.0.4                                ...           2 years ago
  • 1.0.3                                ...           3 years ago
  • 1.0.2                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
  • 0.1.4                                ...           6 years ago
  • 0.1.2                                ...           6 years ago
  • 0.1.1                                ...           6 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (2)
Dependents (0)
None

© 2010 - cnpmjs.org x YWFE | Home | YWFE