Skip to content

lubyxu/mn-cdn-html-webpack-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

目的

基于html-webpack-plugin,不需要额外定义html-webpack-plugin模板的,cdn插入插件。

开发过程中,发现如果webpack进入了不同版本的html-webpack-plugin插件时,这个插件的cdn插入不生效。比如:

- node_modules
  - react-scripts
    - node_modules
      - html-webpack-plugin
  - mn-cdn-html-webpack-plugin
    - node_modules
      - html-webpack-plugin

react-scriptsmn-cdn-html-webpack-plugin引用的不是一个插件,最后会导致本插hook,tap上去了,但是整个complication触发不生效。所以,本插件也不依赖html-webpack-plugin

用法

module.exports = {
  ...
  plugins: [
    new MnCdnHtmlWebpackPlugin({
      externals: [
        {
          type: 'script',
          src: 'https://whale-alivia.oss-cn-hangzhou.aliyuncs.com/lib/aliyun-oss-sdk.6.10.0.min.js',
        },
      ],
    })
  ]
};

typescript的时候,注入到body中。typecss的时候,注入到header中。

About

inject cdn into html

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published