Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions fixture-nextjs-warning-info/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
parser: "postcss-scss",
plugins: {
"postcss-import": {},
},
};
10 changes: 8 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { spawnSync } = require("child_process");
const path = require("path");

module.exports = (css, settings) => {
module.exports = function styledJsxPostcssPlugin(css, settings = {}) {
const cssWithPlaceholders = css.replace(
/%%styled-jsx-placeholder-(\d+)%%/g,
(_, id) => `/*%%styled-jsx-placeholder-${id}%%*/`
Expand Down Expand Up @@ -32,7 +32,13 @@ module.exports = (css, settings) => {
throw new Error(`postcss failed with ${result.stderr}`);
}

return result.stdout.replace(
const { css: outputCss, maybeWarning } = JSON.parse(result.stdout);

if (maybeWarning) {
console.warn(maybeWarning);
}

return outputCss.replace(
/\/\*%%styled-jsx-placeholder-(\d+)%%\*\//g,
(_, id) => `%%styled-jsx-placeholder-${id}%%`
);
Expand Down
Loading