Skip to content

Commit

Permalink
Determine if thread-loader is enabled by checking if emitFile is avai…
Browse files Browse the repository at this point in the history
…lable
  • Loading branch information
non25 committed Jan 19, 2021
1 parent 48f1746 commit f5d5285
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,16 @@ module.exports = function(source, map) {

if (options.emitCss && css.code) {
const resource = posixify(compileOptions.filename);
const cssPath = options.inlineCss
const threadLoaderUsed = this.emitFile === undefined;
const cssPath = threadLoaderUsed
? `${resource}.css`
: `${resource}.${index++}.css`;
const cssQuery = options.inlineCss
const cssQuery = threadLoaderUsed
? `cssData=${Buffer.from(css.code).toString('base64')}`
: `cssPath=${cssPath}`;
css.code += '\n/*# sourceMappingURL=' + css.map.toUrl() + '*/';
js.code += `\nimport '${cssPath}!=!svelte-loader?${cssQuery}!${resource}'\n;`;
if (!options.inlineCss)
if (!threadLoaderUsed)
virtualModules.set(cssPath, css.code);
}

Expand Down

0 comments on commit f5d5285

Please sign in to comment.