Skip to content

Commit

Permalink
feat(loader): runtime exports an object in extract mode
Browse files Browse the repository at this point in the history
In extract mode generated runtime exports object with id, viewBox, url fields and with toString
method. That allows to use svgs from external sprite when rendering symbols by js.

BREAKING CHANGE:
Generated runtime in extract mode is changed from string to object

ISSUES CLOSED: #123
  • Loading branch information
kisenka committed May 21, 2017
1 parent 5513882 commit f0af0eb
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/runtime-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@ function runtimeGenerator(params) {

if (extract) {
const spritePlaceholder = generateSpritePlaceholder(symbol.request.file);

runtime = generateExport(
`__webpack_public_path__ + ${stringify(spritePlaceholder)}`,
esModule
);
const data = {
id: symbol.id,
viewBox: stringify(symbol.viewBox),
url: `__webpack_public_path__ + ${stringify(spritePlaceholder)}`,
toString: function toString() {
return this.url;
}
};

runtime = generateExport(data, esModule);
} else {
const spriteModuleImport = stringifyRequest({ context }, spriteModule);
const symbolModuleImport = stringifyRequest({ context }, symbolModule);
Expand Down

0 comments on commit f0af0eb

Please sign in to comment.