Skip to content

Commit

Permalink
fix(loader): support resourceQuery in extract mode with webpack versi…
Browse files Browse the repository at this point in the history
…on above 1
  • Loading branch information
CXHtml committed Sep 20, 2017
1 parent a1ae646 commit 6652d78
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/utils/mapped-list.js
Expand Up @@ -84,7 +84,7 @@ class MappedList {
const { symbols, spriteModules, allModules, rules } = this;
const data = symbols.reduce((acc, symbol) => {
const resource = symbol.request.file;
const module = spriteModules.find(m => m.resource === resource);
const module = spriteModules.find(m => m.resource.split('?')[0] === resource);
const rule = getMatchedRule(resource, rules);
const options = rule ? getLoaderOptions(spriteLoaderPath, rule) : null;
let spriteFilename = (options && options.spriteFilename)
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/styles4.css
@@ -0,0 +1,3 @@
.img {
background-image: url('img/image.svg?sprite');
}
17 changes: 17 additions & 0 deletions test/loader.test.js
Expand Up @@ -389,5 +389,22 @@ describe('loader and plugin', () => {
it('should emit only built chunks', () => {
// TODO test with webpack-recompilation-emulator
});

if (!webpackVersion.IS_1) {
it('should emit sprite svg when using resourceQuery', async () => {
const { assets } = await compile({
entry: './styles4.css',
module: rules(
Object.assign(svgRule({ extract: true }), {
resourceQuery: /sprite/
}),
cssRule()
),
plugins: [new SpritePlugin()]
});

Object.keys(assets).should.be.lengthOf(2);
});
}
});
});

0 comments on commit 6652d78

Please sign in to comment.