diff --git a/index.js b/index.js index 6599928..8f4c730 100755 --- a/index.js +++ b/index.js @@ -44,13 +44,13 @@ HtmlWebpackExcludeAssetsPlugin.prototype.processAssets = function (excludePatter var head = []; pluginData.head.forEach(function (tag) { - if (!self.isExcluded(excludePatterns, tag.attributes.src)) { + if (!self.isExcluded(excludePatterns, tag.attributes.src || tag.attributes.href)) { head.push(tag); } }); pluginData.body.forEach(function (tag) { - if (!self.isExcluded(excludePatterns, tag.attributes.src)) { + if (!self.isExcluded(excludePatterns, tag.attributes.src || tag.attributes.href)) { body.push(tag); } }); diff --git a/spec/fixtures/exclude.css b/spec/fixtures/exclude.css new file mode 100755 index 0000000..3400472 --- /dev/null +++ b/spec/fixtures/exclude.css @@ -0,0 +1,3 @@ +.exclude { + font-size: 24px; +} diff --git a/spec/index.spec.js b/spec/index.spec.js index 957f427..f928f5c 100755 --- a/spec/index.spec.js +++ b/spec/index.spec.js @@ -50,7 +50,8 @@ describe('HtmlWebpackExcludeAssetsPlugin', function () { webpack({ entry: { app: path.join(__dirname, 'fixtures', 'entry.js'), - style: [path.join(__dirname, 'fixtures', 'app.css')] + styleInclude: path.join(__dirname, 'fixtures', 'app.css'), + styleExclude: path.join(__dirname, 'fixtures', 'exclude.css') }, output: { path: OUTPUT_DIR, @@ -62,7 +63,7 @@ describe('HtmlWebpackExcludeAssetsPlugin', function () { plugins: [ new ExtractTextPlugin('[name].css'), new HtmlWebpackPlugin({ - excludeAssets: [/style.*.js/] + excludeAssets: [/styleInclude.*.js/, /styleExclude.*.css/] }), new HtmlWebpackExcludeAssetsPlugin() ] @@ -72,8 +73,9 @@ describe('HtmlWebpackExcludeAssetsPlugin', function () { fs.readFile(htmlFile, 'utf8', function (er, data) { expect(er).toBeFalsy(); var $ = cheerio.load(data); - expect($('script[src="style.js"]').toString()).toBe(''); - expect($('link[href="style.css"]').toString()).toBe(''); + expect($('script[src="styleInclude.js"]').toString()).toBe(''); + expect($('link[href="styleInclude.css"]').toString()).toBe(''); + expect($('link[href="styleExclude.css"]').toString()).toBe(''); done(); }); });