npm.io
1.2.1 • Published 4 years ago

babel-plugin-alias

Licence
MIT
Version
1.2.1
Deps
0
Size
250 kB
Vulns
0
Weekly
0
Stars
4

babel-plugin-alias

This is an alias conversion babel plugin

Install

install with npm:

npm install --save-dev babel-plugin-alias

install with yarn:

yarn add babel-plugin-alias -dev

Quickstart

Usage 1: integrate into typescript
  1. config tsconfig.json demo(paths is the same as what you normally configure):
{
  "compilerOptions": {
    "baseUrl": "./",
    "paths": {
      "@test/*": ["./test/*"]
    }
  },
}
  1. babel config
  // babel.config.json or .babelrc or babel.config.js
  {
    "plugins": ["babel-plugin-alias"]
  }
  1. file import
  • module test/a.ts
  import b from '@test/b';
  console.log('module a run success !!!', b);
  • module test/b.ts
  console.log('module b run success !!!');
  export default 1;

Keywords