tal-cdn-plugin
v1.0.1
Published
inline code,webpack plugin
Downloads
7
Readme
功能介绍
主要功能: CDN静态资源文件加载失败容错方案。对js、css、img资源加载失败进行了处理。
webpack引入方式
首先npm i tal-cdn-plugin安装插件。
插件本身继承自html-webpack-plugin,因此使用该插件会覆盖html-webpack-plugin,不需要担心html-webpack-plugin功能丢失的问题,使用本插件替代html-webpack-plugin即可。
示例
// webpack配置文件中
const TalCdnPlugin = require('tal-cdn-plugin');
new TalCdnPlugin({
template: './index.html',
filename: 'index.html',
domainNamePool: [
{
reg: /^ucres/,
domains: ['ucres.100tal.com', 'ucres11.100tal.com','ucres12.100tal.com']
}
]
})
// html <head></head>中 所有文件加载之前
<script>
<%= htmlWebpackPlugin.options.inlineCode %>
</script>
字段说明
// domainNamePool字段表示如果不想使用默认域名池可自行定义 格式如上
reg
type: RegExp
原域名的正则匹配规则,填写头部匹配正则表达式。
domains
type: Array
与reg匹配的域名,备份的其他域名。