Skip to content

Commit 69c093a

Browse files
GH-29: Inject the constant CSS rules in the rollup build (GH-30)
1 parent 89eaaec commit 69c093a

File tree

2 files changed

+9
-939
lines changed

2 files changed

+9
-939
lines changed

rollup.config.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,16 @@ const cjsInput5 = {file: "index.cjs.js", format: "cjs", exports: "auto"};
1616
const esmInput5 = {file: "index.esm.js", format: "es"};
1717
const dtsInput5 = {file: "index.d.ts", format: "es"};
1818

19+
const stringifier = (root: any, builder: any) => {
20+
/** Include the CSS rules describing the flags after the main styles */
21+
const style = readFileSync("node_modules/react-phone-input-2/lib/style.css");
22+
const regex = /(\.react-tel-input)\s\.flag.+\1\s*\.\w{2}\b\s*\{[^{}]*}/;
23+
const rules: any = style.toString().match(regex);
24+
builder(root.toString() + "\n" + (rules ? rules[0] : ""));
25+
}
26+
1927
const jsonPlugin = json();
20-
const cssPlugin = postcss();
28+
const cssPlugin = postcss({stringifier});
2129
const tsPlugin = typescript();
2230
const aliasPlugin = alias({entries: {"antd/lib": "antd/es"}});
2331

0 commit comments

Comments
 (0)