Gathering detailed insights and metrics for html-webpack-externals-plugin-modified
Gathering detailed insights and metrics for html-webpack-externals-plugin-modified
Gathering detailed insights and metrics for html-webpack-externals-plugin-modified
Gathering detailed insights and metrics for html-webpack-externals-plugin-modified
Webpack plugin that works alongside html-webpack-plugin to use pre-packaged vendor bundles.
npm install html-webpack-externals-plugin-modified
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
99 Stars
129 Commits
16 Forks
6 Watchers
26 Branches
3 Contributors
Updated on May 29, 2024
Latest Version
2.1.1
Package Id
html-webpack-externals-plugin-modified@2.1.1
Size
4.49 kB
NPM Version
3.10.8
Node Version
6.9.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
This plugin supplements the fantastic html-webpack-plugin by providing a very basic interface for loading your external dependencies.
Webpack developers advise using externals to speed up compile time during development/builds as well as to leverage the caching capabilities of browsers.
This plugin allows you to load external CSS and JS dependencies with:
package.json
and require/import statements will still behave as expected. Script/link tags with the given URLs are appended to the HTML.node_modules
into your build and script/link tags with relative paths are appended to the HTML.1npm install html-webpack-externals-plugin --save-dev
Add it to the plugins
array of your Webpack configuration, after your HtmlWebpackPlugin
instance.
1const HtmlWebpackPlugin = require('html-webpack-plugin'); 2const HtmlWebpackExternalsPlugin = require('html-webpack-externals-plugin'); 3 4module.exports = { 5 // ...your Webpack config 6 plugins: [ 7 new HtmlWebpackPlugin(), 8 new HtmlWebpackExternalsPlugin( 9 // See the API section 10 ); 11 ] 12};
When using this plugin, do not define externals
in the Webpack configuration yourself; it will be written by the plugin at runtime.
An array of objects, each of which represents an external. Each object may have a set of properties, which are documented in the following code sample.
1[ 2 { 3 // The name of the external dependency, i.e. what is passed into `require()` calls or `import` 4 // statements. 5 name: 'react', 6 // JS library dists typically export their API through a single global variable on the `window` 7 // object, e.g. `jQuery` or `React`. If the external does not export anything (e.g. a CSS 8 // dependency), omit this property. 9 var: 'React', 10 // The absolute URL to use when loading the dependency from a CDN. 11 url: 'https://cdnjs.cloudflare.com/ajax/libs/react/15.0.1/react.js' 12 }, 13 { 14 name: 'react', 15 var: 'React', 16 // Alternatively, you can specify a path to a dist file of one of your packages in `node_modules`. 17 // This will copy it to the build directory when Webpack runs. 18 path: 'react/dist/react.min.js' 19 } 20]
An object containing configuration options for the plugin. Both options apply only to local externals (i.e. externals that use path
instead of url
).
1{ 2 // The absolute path to resolve locally installed externals from. Usually this is your 3 // application's root directory. It is required for loading local externals. Most of the time you 4 // can pass `__dirname` to use the current directory. 5 basedir: __dirname, 6 // The directory to copy locally installed externals to within the build directory. Defaults to 7 // `'vendor'`. 8 dest: 'vendor' 9}
1const HtmlWebpackPlugin = require('html-webpack-plugin'); 2const HtmlWebpackExternalsPlugin = require('html-webpack-externals-plugin'); 3 4module.exports = { 5 // ...your Webpack config 6 plugins: [ 7 new HtmlWebpackPlugin(), 8 new HtmlWebpackExternalsPlugin( 9 [ 10 // Using a CDN for a JS library 11 { 12 name: 'jquery', 13 var: 'jQuery', 14 url: 'https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.js' 15 }, 16 // Using a locally installed module for a JS library 17 { 18 name: 'react', 19 var: 'React', 20 path: 'react/dist/react.min.js' 21 }, 22 // Using a CDN for a library with no export (e.g. a CSS module) 23 { 24 name: 'bootstrap.css', 25 url: 'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.css' 26 } 27 ], 28 { 29 // Resolve local modules relative to this directory 30 basedir: __dirname 31 } 32 ); 33 ] 34};
1import React, {Component} from 'react'; 2import $ from 'jquery'; 3// No need to import 'bootstrap.css' because it's already been added to the page
Note that since they are externals, they are always loaded exactly once, whether they are used in source code or not. So this means that it is unnecessary to import the CSS libraries, like Bootstrap.
For local externals (i.e. externals that use path
instead of url
), sometimes you need to copy other assets to the dist that the library depends on (e.g. font assets used by Bootstrap).
The easiest way to accomplish this is by complementing the HtmlWebpackExternalsPlugin with the CopyWebpackPlugin, which copies files in a directory to the build.
In your Webpack configuration's plugins
array, add the plugin after your HtmlWebpackExternalsPlugin instance.
1new CopyWebpackPlugin([
2 {from: 'node_modules/bootstrap/dist/', to: 'vendor/bootstrap/dist/'},
3 {from: 'node_modules/font-awesome/fonts/', to: 'vendor/font-awesome/fonts/'}
4])
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
project is archived
Details
Reason
Found 0/26 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
97 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More