From ad341bf729c1c125d5313b60753d976e1412fe8c Mon Sep 17 00:00:00 2001 From: gxlmyacc Date: Fri, 29 Dec 2017 12:48:14 +0800 Subject: [PATCH 1/2] resolve chunk canot find when chunk name like this "styles/test.css?db562740a398ac3c4f42e7d579e5b365" --- lib/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 41dd888..0f9db36 100644 --- a/lib/index.js +++ b/lib/index.js @@ -4,10 +4,11 @@ function CssChunkHashPlugin(options) { }, options); } +const REGX_CSS = /\S*\.css\??[^.]\S*/; CssChunkHashPlugin.prototype.createCssHash = function ({ assetsByChunkName, publicPath }) { return Object.keys(assetsByChunkName).reduce((hash, name) => { if (!assetsByChunkName[name] || !assetsByChunkName[name].find) return hash; - const file = assetsByChunkName[name].find(file => file.endsWith('.css')); + const file = assetsByChunkName[name].find(file => REGX_CSS.test(file)); if (file) hash[name] = `${publicPath}${file}`; return hash; }, {}); From 76aae8345e082f75a392449682832ff58a77c712 Mon Sep 17 00:00:00 2001 From: gxlmyacc Date: Fri, 29 Dec 2017 15:11:33 +0800 Subject: [PATCH 2/2] fix not find "some.css" --- lib/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 0f9db36..486a11e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -4,11 +4,10 @@ function CssChunkHashPlugin(options) { }, options); } -const REGX_CSS = /\S*\.css\??[^.]\S*/; CssChunkHashPlugin.prototype.createCssHash = function ({ assetsByChunkName, publicPath }) { return Object.keys(assetsByChunkName).reduce((hash, name) => { if (!assetsByChunkName[name] || !assetsByChunkName[name].find) return hash; - const file = assetsByChunkName[name].find(file => REGX_CSS.test(file)); + const file = assetsByChunkName[name].find(file => file.indexOf('.css') >= 0 && file.indexOf('.css.map') < 0); if (file) hash[name] = `${publicPath}${file}`; return hash; }, {});