JSPM

@noxx/babel-plugin-a2rp

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 95
  • Score
    100M100P100Q78253F
  • License MIT

Converts aliases in Strings to relative paths

Package Exports

  • @noxx/babel-plugin-a2rp

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@noxx/babel-plugin-a2rp) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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
    ],
  };
};