Skip to content

About

无需配置 webpack externals 自动向 html-webpack-plugin 模板注入 unpkg cdn

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation

npm node GitHub issues GitHub forks GitHub stars GitHub license

html-webpack-cdn

无需配置 webpack externals 自动向 html-webpack-plugins 模板注入 unpkg cdn

Install

Webpack 5

  npm i --save-dev html-webpack-cdn
  yarn add --dev html-webpack-cdn
// 无需配置 webpack externals
// modules 为空则不会生效
const WebpackHtmlCdnPlugin = require("html-webpack-cdn");

const cdnEnv = process.env.NODE_ENV === 'development' ? 'development' : 'production.min';

new HtmlWebpackCdnPlugin({
  modules: [
    { name: 'react', _var: 'React', path: `umd/react.${cdnEnv}.js` },
    { name: 'react-dom', _var: 'ReactDOM', path: `umd/react-dom.${cdnEnv}.js` },
  ],
})
<!-- html 中效果 -->
<script src="https://unpkg.com/[email protected]/umd/react.production.min.js"></script>
<script src="https://unpkg.com/[email protected]/umd/react-dom.production.min.js"></script>

About

无需配置 webpack externals 自动向 html-webpack-plugin 模板注入 unpkg cdn

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages