Registry / web-framework / html-webpack-externals-plugin

html-webpack-externals-plugin

JSON →
library3.8.0jsnpmunverified

A Webpack plugin v3.8.0 (latest) that works alongside html-webpack-plugin to externalize specified module bundles, injecting script or link tags into the generated HTML. It automates the process of using pre-packaged vendor bundles (e.g., React, Lodash) via CDN or local files, reducing bundle size and improving caching. Unlike webpack's built-in externals, this plugin integrates directly with html-webpack-plugin to add the corresponding <script> or <link> tags. It requires html-webpack-plugin >=2.0.0 as a peer dependency. The plugin has been in maintenance mode with infrequent updates; last release was in 2019. Supports Node >=4.3.0.

npm install html-webpack-externals-plugin
INSTALL
IMPORT
SIG · HTML-WEBPACK-EXTER
H
html-webpack-externals-plugin
web-frameworkjavascriptv3.8.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.

HtmlWebpackExternalsPlugin
const HtmlWebpackExternalsPlugin = require('html-webpack-externals-plugin');
import HtmlWebpackExternalsPlugin from 'html-webpack-externals-plugin';
This package uses CommonJS; no default ESM export is provided.
HtmlWebpackExternalsPlugin
import HtmlWebpackExternalsPlugin = require('html-webpack-externals-plugin');
import { HtmlWebpackExternalsPlugin } from 'html-webpack-externals-plugin';
There is no named export; the plugin is exported as a single constructor.
HtmlWebpackExternalsPlugin (TypeScript)
import HtmlWebpackExternalsPlugin = require('html-webpack-externals-plugin');
import * as HtmlWebpackExternalsPlugin from 'html-webpack-externals-plugin';
TypeScript users should use `import = require()` syntax for CommonJS compatibility. The package does not ship its own type definitions.

Configures webpack to externalize React and ReactDOM via CDN URLs, automatically adding script tags to HTML.

const HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackExternalsPlugin = require('html-webpack-externals-plugin'); module.exports = { entry: './src/index.js', output: { path: './dist', filename: 'bundle.js' }, plugins: [ new HtmlWebpackPlugin({ template: './src/index.html' }), new HtmlWebpackExternalsPlugin({ externals: [ { module: 'react', entry: 'https://unpkg.com/react@16/umd/react.production.min.js', global: 'React' }, { module: 'react-dom', entry: 'https://unpkg.com/react-dom@16/umd/react-dom.production.min.js', global: 'ReactDOM' } ], // Optional: hash the external URLs hash: true, // Optional: specify file type (js or css) filetype: 'js' }) ] };
Debug
Known issues
breakingRequires html-webpack-plugin >= 2.0.0 and < 4.0.0? Not specified but likely incompatible with v4.
fix
Use html-webpack-plugin v3.x or lower. For v4, consider using html-webpack-plugin's built-in script loading or other alternatives.
affects: >=3.0.0
gotchaThe plugin does not automatically add externals to webpack's external config. You must still configure webpack externals manually.
fix
Add `externals: { 'react': 'React', 'react-dom': 'ReactDOM' }` to your webpack config.
affects: >=0.0.0
gotchaThe `global` property must match the global variable name expected by webpack externals and the actual script's global export.
fix
Ensure consistency: the global name in the plugin entry, webpack externals, and the CDN script's object reference all match.
affects: >=0.0.0
deprecatedThe plugin has not been updated since 2019. It may not work with newer webpack versions (4/5).
fix
Consider using `html-webpack-plugin`'s own `externals` option or manually adding scripts via template.
affects: >=3.0.0
Errors
Common errors & fixes
Error: Cannot find module 'html-webpack-externals-plugin'
Package not installed or not resolved correctly.
fix
Run `npm install html-webpack-externals-plugin --save-dev`
TypeError: HtmlWebpackExternalsPlugin is not a constructor
Incorrect import (e.g., using named import instead of default).
fix
Use `const HtmlWebpackExternalsPlugin = require('html-webpack-externals-plugin');`
Error: HookWebpackError: Cannot read property 'tap' of undefined
Incompatible webpack or html-webpack-plugin version hooks.
fix
Ensure html-webpack-plugin is v3.x and webpack is v4.x. The plugin may not work with webpack 5.
Upgrade
Version history
3.8.0latest on npm
Audit
Dependencies
html-webpack-pluginrequiredPeer dependency required for injecting externals into HTML output.
Agent activity
8 hits · last 30 days
node
8
Resources
html-webpack-externals-plugin — npm install html-webpack-externals-plugin · libregistry