Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cra-alias

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cra-alias

Add Webpack aliases to your CRA app, without pain

  • 4.13.19
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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:

JavaScript
  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"
      }
    
TypeScript
  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"
      }
    

Keywords

FAQs

Package last updated on 01 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc