实现webpack插件
要安装 html-webpack-plugin@next
InlineSourcePlugin.js
// 把外链的标签, 变成内联的标签
let HtmlWebpackPlugin = require('html-webpack-plugin');
class InlineSourcePlugin {
constructor({
match}) {
this.reg = match;
}
processTag(tag, compilation) {
let newTag, url;
if (tag.tagName === 'link' && this.reg.test(tag.attributes.href)) {
newTag = {
tagName: 'style',
attributes: {
type: 'text/css'}
};
url = tag.attributes.href;
}
if (tag.tagName === 'script' && this.reg.test