Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

neetly/project-references-webpack-plugin

Repository files navigation

Project References Webpack Plugin

CI npm version

yarn add --dev project-references-webpack-plugin
// webpack.config.ts
import { ProjectReferencesPlugin } from "project-references-webpack-plugin";
import type { Configuration } from "webpack";

const config: Configuration = {
  resolve: {
    extensions: [".ts", ".tsx", ".js"],
    extensionAlias: {
      ".js": [".ts", ".tsx", ".js"],
      ".mjs": [".mts", ".mjs"],
      ".cjs": [".cts", ".cjs"],
    },
    plugins: [new ProjectReferencesPlugin()],
  },
};

export default config;

Example

import "library"; // => packages/library/src/index.ts
// packages/library/package.json
{
  "name": "library",
  "main": "./lib/index.js",
}
// packages/library/tsconfig.json
{
  "compilerOptions": {
    "rootDir": "./src",
    "outDir": "./lib",
  },
}

Credit

This project was inspired by webpack-project-references-alias.