@noxx/babel-plugin-a2rp

1.0.1 • Public • Published

Babel Plugin - Aliases to Relative Paths

Build Status npm version

Converts aliases in Strings to relative paths


Install

npm i -D @noxx/babel-plugin-a2rp

Usage

First create aliases that can be utilized by the plugin. The format for the aliases Object are key value pairs where the key is the alias, and value is the actual path that maps to a specific directory.

// aliases.js
const { resolve } = require('path');

const ROOT = resolve(__dirname, './');
const SRC = `${ ROOT }/src`;

module.exports = {
  COMPONENTS: `${ SRC }/components`,
  SERVER: `${ SRC }/server`,
};

In your babel.config.js file, add the plugin at the top of the plugins list to ensure aliases are replaced and paths are resolved correctly.

const aliases = require('./aliases');

module.exports = (api) => {
  api.cache(true);
  
  return {
    plugins: [
      ['@noxx/babel-plugin-a2rp', { aliases }],
      // other plugins
    ],
  };
};

Package Sidebar

Install

npm i @noxx/babel-plugin-a2rp

Weekly Downloads

19

Version

1.0.1

License

MIT

Unpacked Size

4.45 kB

Total Files

4

Last publish

Collaborators

  • noxx