Gathering detailed insights and metrics for html-webpack-inject-externals-plugin
Gathering detailed insights and metrics for html-webpack-inject-externals-plugin
Gathering detailed insights and metrics for html-webpack-inject-externals-plugin
Gathering detailed insights and metrics for html-webpack-inject-externals-plugin
html-webpack-plugin inject externals tags
npm install html-webpack-inject-externals-plugin
Typescript
Module System
Node Version
NPM Version
TypeScript (81.43%)
JavaScript (17.94%)
HTML (0.63%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
1 Stars
41 Commits
1 Watchers
2 Branches
1 Contributors
Updated on Jul 22, 2022
Latest Version
0.1.14
Package Id
html-webpack-inject-externals-plugin@0.1.14
Unpacked Size
17.89 kB
Size
5.73 kB
File Count
7
NPM Version
9.8.1
Node Version
18.18.0
Published on
Nov 16, 2023
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
2
31
根据外部依赖配置,自动生成并插入script或link标签。
By configure externals packages settings, auto inject script or link tag into html template.
仅支持webpack > 5
Only works with webpack 5 and html-webpack-plugin 5.
To work with webpack 4, try https://github.com/shirotech/webpack-cdn-plugin
.
与html-webpack-plugin
一起使用,将项目中的外部依赖自动按版本号生成script或link标签,注入html文件的header中。
目前支持依据加载路径的后缀名生成标签,.css
生成link
标签,其他的都生成script标签。
Work together with html-webpack-plugin
, get your project dependencies correct version to generate script or link tag, then inject them into your html template header.
For now only support suffix with .css
for link
tag, all other suffixes will be script
tags.
yarn add html-webpack-inject-externals-plugin
1const { HtmlWebpackInjectExternalsPlugin } from 'html-webpack-inject-externals-plugin' 2const isProd = process.env.NODE_ENV === 'production' 3 4 ... 5 plugins: [ 6 new HtmlWebpackInjectExternalsPlugin({ 7 externals: { 8 history: 'History', 9 }, 10 host: 'https://unpkg.com', 11 packages: [ 12 { 13 name: 'history', 14 path: `/umd/history.${isProd ? 'min.' : ''}js`, 15 }, 16 ], 17 }) 18 ]
以上配置可生成script标签并插入document.head,如下
Above config will generate result like:
1<!--开发环境/development env --> 2<script src="https://unpkg.com/history@4.10.1/umd/history.js"></script> 3<!--生产环境/production env --> 4<script src="https://unpkg.com/history@4.10.1/umd/history.min.js"></script>
其中的版本号以当前项目所依赖的版本号保持一致。
The version
part will be your project real dependencies version.
💡 必须与html-webpack-plugin
一起使用。
Must work with html-webpack-plugin
together.
💡 html-webpack-plugin
版本需要 > 4
。
Require html-webpack-plugin
version >4
.
🍾 兼容webpack 5
,在next
分支上测试。
Compatible with webpack 5
, tested in next
branch.
1const { HtmlWebpackInjectExternalsPlugin } = require('html-webpack-inject-externals-plugin')
1import { HtmlWebpackInjectExternalsPlugin } from 'html-webpack-inject-externals-plugin'
1 plugins: [ 2 ..., 3 new HtmlWebpackPlugin({ 4 inject: true, 5 template: './public/index.html', 6 }), 7 new HtmlWebpackInjectExternalsPlugin({ 8 // externals项,非必须,可以写在这里,也可以直接写在webpack的externals中。 9 externals: { 10 history: 'History', 11 }, 12 host: 'https://unpkg.com', 13 packages: [ 14 { 15 name: 'history', 16 path: '/umd/history.js', 17 }, 18 { 19 name: 'animate.css', 20 fullPath: 'https://unpkg.com/animate.css@4.1.0/animate.css', 21 }, 22 ], 23 }) 24 ]
interface OPTION {
// same with webpack externals. as below:
// {
// react: 'React'
// 'antd/lib/locale/zh_CN': ['antd', 'locales', 'zh_CN'],
// }
// this is optional, set it at webpack config part, works the same way.
externals?: {
[packageName: string]: string | string[]
}
// full host with protocol, like "https://unpkg.com"
host?: string
// your externals dependencies
packages: {
/**
* 如果有的包需要从其他站点或路径引入,
* 可配置其他的类似unpkg功能的地址
* 一般不需要单独配置
* @example https://unpkg.my.com
* */
host?: string
/**
* 包名称
* */
name: string
/**
* 需要引用的包内的文件路径
* @example `/umd/react.${isProd ? 'production.min' : 'development'}.js`
*/
path?: string
/**
* 使用fullPath则完全使用该项,不再从模块的package.json中自动拼接路径
* @example: http://cdnjs.com/react/react.min.prodjction.js
* */
fullPath?: string
/**
* 定制标签属性
* */
attributes?: Record<string, string | boolean>
/**
* 默认按path或fullPath中的后缀名判断,js为script,css为link
* 没有后缀默认按script
* 也可以使用该项指定,覆盖自动判断行为
* */
tagName?: string
/**
* 每个标签前面面,可以自定义一个跟随的标签
* 内容完全自定义
* */
injectBefore?: HtmlTagObject
/**
* 每个标签后面,可以自定义一个跟随的标签
* 内容完全自定义
* */
injectAfter?: HtmlTagObject
/**
* 是否采用本地模式,即将node_modules中的文件复制到发布文件夹中
* 使用了fullPath的package不会处理
* */
local?: boolean
/**
* 本地模式配合使用的文件夹前缀
* 例如 /assets 或 /static
* */
localPrefix?: string
}[]
}
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
Found 0/30 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
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
27 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
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