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
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>