JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q24611F
  • License MIT

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

Package Exports

  • html-webpack-cdn

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (html-webpack-cdn) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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/react@17.0.2/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@17.0.2/umd/react-dom.production.min.js"></script>