-
-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathindex.js
More file actions
22 lines (18 loc) · 565 Bytes
/
index.js
File metadata and controls
22 lines (18 loc) · 565 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const compile = require("./compile");
const error = require("./error");
module.exports = (css, settings) => {
const cssWithPlaceholders = css.replace(
/%%styled-jsx-placeholder-(\d+)%%/g,
(_, id) => `/*%%styled-jsx-placeholder-${id}%%*/`
);
const result = compile(cssWithPlaceholders, settings);
if (!result) {
error(
`did not compile the following CSS:\n\n${css.split("\n").join("\n\t")}\n`
);
}
return result.replace(
/\/\*%%styled-jsx-placeholder-(\d+)%%\*\//g,
(_, id) => `%%styled-jsx-placeholder-${id}%%`
);
};