npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

alias-to-config-plugin

v1.0.5

Published

Automatically generate jsconfig.json/tsconfig.json path mappings from Webpack/Vite alias configurations

Readme

alias-to-config-plugin

English | 中文

Automatically generate jsconfig.json/tsconfig.json path mappings from Webpack/Vite alias configurations.

🎯 Features

  • Auto-sync aliases: Automatically converts Webpack/Vite alias configurations to jsconfig.json/tsconfig.json path mappings
  • Smart detection: Intelligently detects whether to use jsconfig.json or tsconfig.json
  • Multiple formats support: Compatible with Webpack object format, Vite object format, and Vite array format
  • Flexible filtering: Support for excluding specific aliases or paths using regex patterns
  • Performance optimized: Skip file writes when configuration hasn't changed
  • TypeScript ready: Full TypeScript support with comprehensive type definitions
  • Zero config: Works out of the box with sensible defaults

📦 Installation

npm install alias-to-config-plugin --save-dev

Or using yarn:

yarn add alias-to-config-plugin --dev

Or using pnpm:

pnpm add alias-to-config-plugin --dev

🚀 Usage

Import Methods

You can import the plugins using different methods:

Method 1: Named Import (Recommended)

import {
  ViteAliasToConfigPlugin,
  WebpackAliasToConfigPlugin,
} from "alias-to-config-plugin";

Method 2: Subpath Import

// For Vite
import ViteAliasToConfigPlugin from "alias-to-config-plugin/vite";

// For Webpack
import WebpackAliasToConfigPlugin from "alias-to-config-plugin/webpack";

Method 3: CommonJS (Webpack)

const { WebpackAliasToConfigPlugin } = require("alias-to-config-plugin");
// or
const WebpackAliasToConfigPlugin = require("alias-to-config-plugin/webpack");

Vite Plugin

// vite.config.js
import { defineConfig } from "vite";
import createAliasToConfigPlugin from "alias-to-config-plugin/vite";

export default defineConfig({
  plugins: [
    createAliasToConfigPlugin({
      // Optional: custom jsconfig.json path
      configPath: "./jsconfig.json",
      // Optional: custom baseUrl
      baseUrl: ".",
      // Optional: exclude specific aliases
      excludeAlias: ["@test", "@mock"],
      // Optional: exclude aliases matching regex
      excludeAliasReg: /^@test/,
      // Optional: exclude paths matching regex
      excludeAliasPathReg: /node_modules/,
    }),
  ],
  resolve: {
    alias: {
      "@": "./src",
      "@components": "./src/components",
      "@utils": "./src/utils",
    },
  },
});

Webpack Plugin

// webpack.config.js
const { WebpackAliasToConfigPlugin } = require("alias-to-config-plugin");

module.exports = {
  plugins: [
    new WebpackAliasToConfigPlugin({
      configPath: "./jsconfig.json",
      baseUrl: ".",
    }),
  ],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "src"),
      "@components": path.resolve(__dirname, "src/components"),
    },
  },
};

Standalone Usage

import ConfigGenerator from "alias-to-config-plugin/configGenerator";

const generator = new ConfigGenerator({
  configPath: "./jsconfig.json",
  baseUrl: ".",
});

// Generate config from alias object
generator.generateConfig({
  "@": "./src",
  "@components": "./src/components",
});

📋 Configuration Options

| Option | Type | Default | Description | | --------------------- | ---------- | ------------- | ----------------------------------------------------- | | enable | boolean | true | Enable/disable the plugin | | configPath | string | Auto-detected | Path to jsconfig.json or tsconfig.json | | baseUrl | string | "." | Base URL for path resolution | | excludeAlias | string[] | [] | Array of alias names to exclude | | excludeAliasReg | RegExp | null | Regex pattern to exclude aliases | | excludeAliasPathReg | RegExp | null | Regex pattern to exclude paths |

🔧 How It Works

  1. Detection: Automatically detects whether to use jsconfig.json or tsconfig.json
  2. Normalization: Converts various alias formats (Webpack object, Vite object/array) to a unified format
  3. Path Mapping: Transforms aliases into jsconfig/tsconfig path mappings
  4. Smart Merging: Merges with existing configuration, preserving user settings
  5. Optimization: Skips file writes when configuration hasn't changed

💡 Examples

Input Alias Configuration

// Vite/Webpack alias
{
  '@': './src',
  '@components': './src/components',
  '@utils': './src/utils',
  '@assets': './src/assets'
}

Generated jsconfig.json

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@": ["./src"],
      "@/*": ["./src/*"],
      "@components": ["./src/components"],
      "@components/*": ["./src/components/*"],
      "@utils": ["./src/utils"],
      "@utils/*": ["./src/utils/*"],
      "@assets": ["./src/assets"],
      "@assets/*": ["./src/assets/*"]
    }
  }
}

🎨 Advanced Usage

Excluding Specific Aliases

ViteAliasToConfigPlugin({
  excludeAlias: ["@test", "@mock"],
  excludeAliasReg: /^@(test|mock)/,
  excludeAliasPathReg: /node_modules/,
});

🔗 Compatibility

  • Node.js: >= 14.0.0

📊 Performance

  • Fast: Optimized for large codebases with 1500+ aliases
  • Efficient: Skip unnecessary file writes
  • Memory-friendly: Minimal memory footprint

🧪 Testing

# Run tests
npm test

# Run tests with coverage
npm run test:coverage

# Run performance tests
npm run test:run

📄 License

MIT License

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📞 Support

If you have any questions or issues, please open an issue on GitHub.