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]}");`; }, ], }),