Skip to content

Commit

Permalink
Merge pull request #190 from CXHtml/fix-resourceQuery-bug
Browse files Browse the repository at this point in the history
fix(loader): support resourceQuery in extract mode with webpack above v1
  • Loading branch information
kisenka authored Sep 27, 2017
2 parents 75df92e + 9f1d12b commit a07c1f7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/utils/mapped-list.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.img {
background-image: url('img/image.svg?sprite');
}
15 changes: 15 additions & 0 deletions test/loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,21 @@ describe('loader and plugin', () => {
Object.keys(assets).should.be.lengthOf(2);
assets.should.have.property('lvn29bpor3.svg');
});

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 a07c1f7

Please sign in to comment.