4.13.19 • Published 5 years ago

cra-alias v4.13.19

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

IMPORTANT NOTE

This package is NO LONGER MAINTAINED, please use craco-alias instead.

cra-alias

npm Travis (.org)

You don't need to eject your App to add aliases!

List of Contents

Main Advantages

  • cra-alias uses standard jsconfig.json and tsconfig.json files, so you don't have to create any extra configuration files (like config-overrides.js)

  • cra-alias automatically generates moduleNameMapper for Jest, according to your js(ts)config.json

Checklist

  • Support npm start
  • Support npm run build
  • Support npm test
  • Support TypeScript CRA
  • Support extra cli arguments
  • Add TypeScript example to README

Installation

Install the package:

npm i -D cra-alias

The next steps depend on the language:

  1. Go to project's root directory.

  2. Create (or open if exists) jsconfig.json.

  3. Edit it as follows:

    {
      "compilerOptions": {
        "baseUrl": "src", // only 'src' or 'node_modules'
        "paths": {
          "@file-alias": ["./your/file.js"],
          "@folder-alias/*": ["./very/long/path/*", "./very/long/path/"]
        }
      }
    }
  4. Go to package.json

  5. Replace react-scripts with cra-alias, like that:

      "scripts": {
    -   "start": "react-scripts start",
    +   "start": "cra-alias start",
    -   "build": "react-scripts build",
    +   "build": "cra-alias build",
    -   "test": "react-scripts test",
    +   "test": "cra-alias test",
        "eject": "react-scripts eject"
      }
  1. Go to project's root directory.

  2. Create tsconfig.paths.json.

  3. Edit it as follows:

    {
      "compilerOptions": {
        "baseUrl": "src", // only 'src' or 'node_modules'
        "paths": {
          "@file-alias": ["./your/file.tsx"],
          "@folder-alias/*": ["./very/long/path/*", "./very/long/path/"]
        }
      }
    }
  4. Go to tsconfig.json.

  5. Add the following line to the beginning of the file:

    {
    + "extends": "./tsconfig.paths.json",
      "compilerOptions": {
        "target": "es5",
        ...
      },
      ...
    }
  6. Go to package.json.

  7. Replace react-scripts with cra-alias, like that:

      "scripts": {
    -   "start": "react-scripts start",
    +   "start": "cra-alias start",
    -   "build": "react-scripts build",
    +   "build": "cra-alias build",
    -   "test": "react-scripts test",
    +   "test": "cra-alias test",
        "eject": "react-scripts eject"
      }
4.13.19

5 years ago

4.13.18

5 years ago

4.13.17

5 years ago

4.13.16

5 years ago

4.13.15

5 years ago

4.13.14

5 years ago

4.13.13

5 years ago

4.13.12

5 years ago

4.13.11

5 years ago

4.12.11

5 years ago

4.10.11

5 years ago

4.10.10

5 years ago

4.9.10

5 years ago

4.8.9

5 years ago

4.8.8

5 years ago

4.8.7

5 years ago

4.7.7

5 years ago

4.6.7

5 years ago

3.6.7

5 years ago

3.4.7

5 years ago

3.4.6

5 years ago

3.4.5

5 years ago

3.4.4

5 years ago

3.3.4

5 years ago

2.3.4

5 years ago

2.2.4

5 years ago

2.1.4

5 years ago

2.1.3

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago