From a03f2845f7f3a0838af71e60a3c391e1e9e243dd Mon Sep 17 00:00:00 2001 From: Mario Subotic Date: Fri, 12 Aug 2022 11:07:04 +0800 Subject: [PATCH] fix(build): fix css injection fix css injection tryiong to inject at buildtime instead of runtime --- lib/rollup.config.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/rollup.config.js b/lib/rollup.config.js index a8f0d028b..f7bb11a0a 100644 --- a/lib/rollup.config.js +++ b/lib/rollup.config.js @@ -9,11 +9,12 @@ const components = require("./src/index.json"); function injectCSS(css, uniqueId) { if (!css || typeof document === "undefined") { + console.error("injectCSS error: no css or document undefined "); return; } const exists = !!document.querySelector(`style[id="${uniqueId}"]`); - if (exists) { + if (uniqueId && exists) { return; } @@ -50,7 +51,7 @@ export default [ (varname, id) => { const filePathArray = id.split("\\"); const file = filePathArray[filePathArray.length - 1].split("."); - return `${varname} = ${injectCSS(varname, `rc-${file[0]}`)};`; + return `const inject = ${injectCSS};\n${varname} = inject(${varname}, "rc-${file[0]}");`; }, ], }), @@ -78,7 +79,7 @@ export default [ (varname, id) => { const filePathArray = id.split("\\"); const file = filePathArray[filePathArray.length - 1].split("."); - return `${varname} = ${injectCSS(varname, `rc-${file[0]}`)};`; + return `const inject = ${injectCSS};\n${varname} = inject(${varname}, "rc-${file[0]}");`; }, ], }),