Skip to content
Permalink
Browse files

feat: Include Style String in Webpack Loader Output (#567)

  • Loading branch information...
cpinnix authored and tivac committed Mar 4, 2019
1 parent 1a84b5d commit 6d883ac12c72818fbc7d868c18f1c6f5b453bed7
Showing with 26 additions and 24 deletions.
  1. +4 −2 packages/webpack/loader.js
  2. +22 −22 packages/webpack/test/__snapshots__/webpack.test.js.snap
@@ -37,19 +37,21 @@ module.exports = async function(source) {
if(options.namedExports === false) {
return done(null, out.join("\n"));
}

// Warn if any of the exported CSS wasn't able to be used as a valid JS identifier
// and exclude from the output
Object.keys(exported).forEach((ident) => {
if(keyword.isReservedWordES6(ident) || !keyword.isIdentifierNameES6(ident)) {
this.emitWarning(new Error(`Invalid JS identifier "${ident}", unable to export`));

return;
}

out.push(`export var ${ident} = ${JSON.stringify(exported[ident])};`);
});

out.push(`export var styles = ${JSON.stringify(result.details.result.css)};`);

return done(null, out.join("\n"));
} catch(e) {
return done(e);
Oops, something went wrong.

0 comments on commit 6d883ac

Please sign in to comment.
You can’t perform that action at this time.