1.0.24 • Published 5 years ago

cra-rewired v1.0.24

Weekly downloads
6
License
MIT
Repository
github
Last release
5 years ago

cra-rewired

You can add loaders or change other webpack configs without npm run eject from create-react-app

Examples

Quick Overview

create-react-app my-app
cd my-app
npm install cra-rewired --save-dev
echo "SKIP_PREFLIGHT_CHECK=true" >> .env

Then create a custom options file. This example adds a loader that loads the contents of the yaml file json.

// webpack.custom.js
module.exports = function (paths) {
  return {
    // path in webpack.config
    'module.rules...oneOf': {
      // operation: $unshift | $push | $set
      $unshift: [
        {
          test: /\.(yml|yaml)$/,
          include: paths.appSrc,
          use: ['json-loader', 'yaml-loader']
        }
      ]
    }
  };
};

Update scripts.start in package.json as follows.

{
  ...
  "scripts": {
    "start_old": "react-scripts start",
    "start": "cra-rewired -s react-scripts -m start -c webpack.custom.js",
    ...
  },
  ...
}

Now you can import yaml file contents.

import data from './data.yml';

console.log(data); // { message: 'hello world' }
1.0.24

5 years ago

1.0.23

5 years ago

1.0.22

6 years ago

1.0.21

6 years ago

1.0.20

6 years ago

1.0.19

6 years ago

1.0.18

6 years ago

1.0.17

6 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago