🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

alias-reuse

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alias-reuse

Reuse custom or existing aliases from one configuration in others

latest
Source
npmnpm
Version
3.0.6
Version published
Maintainers
1
Created
Source

⚙️ Alias reuse

Version Small size Build Test

Reuse custom or existing aliases from one configuration in others.

.

Install

npm i alias-reuse --save-dev

.

Usage

Import

Import aliases from existing configuration. The library will automatically detect the configuration source type.

Supported configuration sources:

  • tsconfig
  • webpack / vite
  • object
reuse().from(pathToConfig: string);

... and also from custom object.

reuse().from(config: Record<string, string>);

Configure

Set custom root directory.

reuse().from(...).at(pathToRoot: string);

Export

Export of aliases in a required configuration target.

Supported configuration targets:

  • tsconfig
  • webpack / vite
  • jest
  • object
reuse().from(...).for(target: string);

.

Examples

  • Example for Webpack

const { reuse } = require('alias-reuse');
const tsconfigPath = path.join(__dirname, 'tsconfig.json');

module.exports = {
  resolve: {
    alias: reuse()
      .from(tsconfigPath) // Import aliases from tsconfig.json
      .for("webpack"), // And convert to webpack format
  },
  // ...
};
  • Example for TSConfig

const { reuse } = require('alias-reuse');
const configPath = path.join(__dirname, 'configs/aliases.json');

module.exports = {
  compilerOptions: {
    paths: reuse()
      .from(configPath) // Import aliases from custom config
      .for("tsconfig"), // And convert to tsconfig format
  },
  // ...
};
  • Example with custom root directory

const { reuse } = require('alias-reuse');
const rootPath = path.join(__dirname, 'root');
const configPath = path.join(__dirname, 'configs/aliases.json');

module.exports = {
  resolve: {
    alias: reuse()
      .from(configPath) // Import aliases from custom config
      .at(rootPath) // Set root directory
      .for("vite"), // And convert to vite format
  },
  // ...
};

Keywords

alias

FAQs

Package last updated on 15 Jun 2025

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