Registry / devops / symlink-webpack-plugin

symlink-webpack-plugin

JSON →
library1.1.0jsnpmunverified

A Webpack plugin to create symbolic links for emitted files. Current stable version is 1.1.0 (released in 2022). The plugin runs after Webpack's emit phase (by default) to create symlinks from one built file to another. It supports array configuration for multiple symlinks, a force option to create missing directories, and a hook option to specify the exact compiler hook (e.g., entryOption). Designed for static site deployments where a single-file router (like index.html) must also appear under a different name (e.g., 200.html). Works with Webpack 4 and 5. Maintained but low churn.

npm install symlink-webpack-plugin
INSTALL
IMPORT
SIG · SYMLINK-WEBPACK-PL
S
symlink-webpack-plugin
devopsjavascriptv1.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SymlinkWebpackPlugin
const SymlinkWebpackPlugin = require('symlink-webpack-plugin');
import SymlinkWebpackPlugin from 'symlink-webpack-plugin';
Package is CommonJS only; ESM import will fail. Use require.
SymlinkWebpackPlugin
plugins: [new SymlinkWebpackPlugin({ origin: 'index.html', symlink: '200.html' })]
plugins: [SymlinkWebpackPlugin({ origin: 'index.html', symlink: '200.html' })]
Must use the 'new' keyword. The plugin is a constructor.
SymlinkWebpackPlugin
const SymlinkWebpackPlugin = require('symlink-webpack-plugin');
const SymlinkWebpackPlugin = require('symlink-webpack-plugin').default;
There is no default export; direct require returns the constructor.

Configures SymlinkWebpackPlugin to create a symlink from 'index.html' to '200.html' after Webpack emits files.

// webpack.config.js const SymlinkWebpackPlugin = require('symlink-webpack-plugin'); const path = require('path'); module.exports = { entry: './src/index.js', output: { path: path.resolve(__dirname, 'dist'), filename: 'bundle.js', }, plugins: [ new SymlinkWebpackPlugin({ origin: 'index.html', symlink: '200.html' }) ] };
Debug
Known issues
breakingv1.0.0 drops support for Webpack 2 and 3. Requires Webpack 4+.
fix
Upgrade Webpack to version 4 or later. If stuck on older Webpack, use v0.2.0 (last version supporting Webpack 2/3).
affects: >=1.0.0
gotchaThe default hook is 'afterEmit'. If your Webpack config uses a different emit-like hook (e.g., 'afterProcessAssets'), symlinks may not be created at the expected time.
fix
Explicitly set 'hook' option to the desired compiler hook (e.g., 'thisCompilation', 'emit', 'afterProcessAssets').
affects: >=1.0.0
gotchaWhen 'force' is false (default), the plugin will silently skip symlinks whose target directory does not exist. No error is thrown.
fix
Set 'force: true' to create missing directories, or ensure the directory structure exists before the build.
affects: >=1.0.0
deprecatedThe package relies on 'fs-extra' for directory creation. Webpack 5 has native support for 'mkdirRecursive', but this plugin does not use it.
fix
No immediate action required; the dependency is stable. Future versions might drop fs-extra.
affects: >=1.1.0
Errors
Common errors & fixes
Error: Cannot find module 'symlink-webpack-plugin'
Missing installation or wrong import path in a monorepo.
fix
Run npm install --save-dev symlink-webpack-plugin or yarn add --dev symlink-webpack-plugin.
TypeError: SymlinkWebpackPlugin is not a constructor
Used import incorrectly (ESM default import) or forgot 'new'.
fix
Use const SymlinkWebpackPlugin = require('symlink-webpack-plugin'); then new SymlinkWebpackPlugin(...).
SymlinkWebpackPlugin: symlink option should be a string for non-array configuration
Passed an object without 'symlink' property, or passed a non-string value.
fix
Ensure each configuration object has 'origin' and 'symlink' as strings. For multiple symlinks, pass an array of objects.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies
fs-extrarequiredUsed internally for filesystem operations (ensuring directory existence with force option).
Agent activity
11 hits · last 30 days
node
8
OpenAI (training)
2
Resources
symlink-webpack-plugin — npm install symlink-webpack-plugin · libregistry