Skip to content

Commit

Permalink
GH-29: Inject the constant CSS rules in the rollup build (GH-30)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtyomVancyan authored Mar 27, 2023
1 parent 89eaaec commit 69c093a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 939 deletions.
10 changes: 9 additions & 1 deletion rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@ const cjsInput5 = {file: "index.cjs.js", format: "cjs", exports: "auto"};
const esmInput5 = {file: "index.esm.js", format: "es"};
const dtsInput5 = {file: "index.d.ts", format: "es"};

const stringifier = (root: any, builder: any) => {
/** Include the CSS rules describing the flags after the main styles */
const style = readFileSync("node_modules/react-phone-input-2/lib/style.css");
const regex = /(\.react-tel-input)\s\.flag.+\1\s*\.\w{2}\b\s*\{[^{}]*}/;
const rules: any = style.toString().match(regex);
builder(root.toString() + "\n" + (rules ? rules[0] : ""));
}

const jsonPlugin = json();
const cssPlugin = postcss();
const cssPlugin = postcss({stringifier});
const tsPlugin = typescript();
const aliasPlugin = alias({entries: {"antd/lib": "antd/es"}});

Expand Down
Loading

0 comments on commit 69c093a

Please sign in to comment.