{"id":20601,"library":"symlink-webpack-plugin","title":"SymlinkWebpackPlugin","description":"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.","status":"active","version":"1.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/hmsk/symlink-webpack-plugin","tags":["javascript","webpack","plugin","symlink"],"install":[{"cmd":"npm install symlink-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add symlink-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add symlink-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used internally for filesystem operations (ensuring directory existence with force option).","package":"fs-extra","optional":false}],"imports":[{"note":"Package is CommonJS only; ESM import will fail. Use require.","wrong":"import SymlinkWebpackPlugin from 'symlink-webpack-plugin';","symbol":"SymlinkWebpackPlugin","correct":"const SymlinkWebpackPlugin = require('symlink-webpack-plugin');"},{"note":"Must use the 'new' keyword. The plugin is a constructor.","wrong":"plugins: [SymlinkWebpackPlugin({ origin: 'index.html', symlink: '200.html' })]","symbol":"SymlinkWebpackPlugin","correct":"plugins: [new SymlinkWebpackPlugin({ origin: 'index.html', symlink: '200.html' })]"},{"note":"There is no default export; direct require returns the constructor.","wrong":"const SymlinkWebpackPlugin = require('symlink-webpack-plugin').default;","symbol":"SymlinkWebpackPlugin","correct":"const SymlinkWebpackPlugin = require('symlink-webpack-plugin');"}],"quickstart":{"code":"// webpack.config.js\nconst SymlinkWebpackPlugin = require('symlink-webpack-plugin');\nconst path = require('path');\n\nmodule.exports = {\n  entry: './src/index.js',\n  output: {\n    path: path.resolve(__dirname, 'dist'),\n    filename: 'bundle.js',\n  },\n  plugins: [\n    new SymlinkWebpackPlugin({ origin: 'index.html', symlink: '200.html' })\n  ]\n};","lang":"javascript","description":"Configures SymlinkWebpackPlugin to create a symlink from 'index.html' to '200.html' after Webpack emits files."},"warnings":[{"fix":"Upgrade Webpack to version 4 or later. If stuck on older Webpack, use v0.2.0 (last version supporting Webpack 2/3).","message":"v1.0.0 drops support for Webpack 2 and 3. Requires Webpack 4+.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Explicitly set 'hook' option to the desired compiler hook (e.g., 'thisCompilation', 'emit', 'afterProcessAssets').","message":"The 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set 'force: true' to create missing directories, or ensure the directory structure exists before the build.","message":"When 'force' is false (default), the plugin will silently skip symlinks whose target directory does not exist. No error is thrown.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"No immediate action required; the dependency is stable. Future versions might drop fs-extra.","message":"The package relies on 'fs-extra' for directory creation. Webpack 5 has native support for 'mkdirRecursive', but this plugin does not use it.","severity":"deprecated","affected_versions":">=1.1.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run npm install --save-dev symlink-webpack-plugin or yarn add --dev symlink-webpack-plugin.","cause":"Missing installation or wrong import path in a monorepo.","error":"Error: Cannot find module 'symlink-webpack-plugin'"},{"fix":"Use const SymlinkWebpackPlugin = require('symlink-webpack-plugin'); then new SymlinkWebpackPlugin(...).","cause":"Used import incorrectly (ESM default import) or forgot 'new'.","error":"TypeError: SymlinkWebpackPlugin is not a constructor"},{"fix":"Ensure each configuration object has 'origin' and 'symlink' as strings. For multiple symlinks, pass an array of objects.","cause":"Passed an object without 'symlink' property, or passed a non-string value.","error":"SymlinkWebpackPlugin: symlink option should be a string for non-array configuration"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}