为html页面中的js与css添加cdn域名

安装

npm install webpack-absolute-path --save-dev 使用

webpack.config.js plugins: [ new HtmlWebpackPlugin({ //html-webpack-plugin 必须装,因为在这个插件上拓展 filename: xxx.html, template: xxx.html, inject:true, hash: false, cache: true, minify:{ //压缩HTML文件 removeComments:true, //移除HTML中的注释 collapseWhitespace:true, //删除空白符与换行符 } }), new HtmlAbsolutePath({ cssDomain:'http://xxxxxxxxxxx', //支持 字符串与['http://11.xxxx','http://22.xxxx'] jsDomain:'http://xxxxxxxxxxx' }) ]

逻辑: 当插件html-webpack-plugin输出一个html页面时,会对页面的css,js资源进行扫描,替换其域名;

(欢迎反馈BUG,方便提升插件的质量)

版权声明:

1、该文章(资料)来源于互联网公开信息,我方只是对该内容做点评,所分享的下载地址为原作者公开地址。
2、网站不提供资料下载,如需下载请到原作者页面进行下载。