diff --git a/scripts/removeDarkmode.js b/scripts/removeDarkmode.js index b04b2e7..bc4b193 100644 --- a/scripts/removeDarkmode.js +++ b/scripts/removeDarkmode.js @@ -10,10 +10,6 @@ const path = require("path"); ]; const configFiles = [ - { - filePath: "tailwind.config.js", - patterns: ["darkmode:\\s*{[^}]*},", 'darkMode:\\s*"class",'], - }, { filePath: "src/config/theme.json", patterns: ["colors.darkmode"] }, ]; @@ -71,13 +67,9 @@ const path = require("path"); function removeDarkMode(configFile) { const { filePath, patterns } = configFile; - if (filePath === "tailwind.config.js") { - removeDarkModeFromFiles(filePath, patterns); - } else { - const contentFile = JSON.parse(fs.readFileSync(filePath, "utf8")); - patterns.forEach((pattern) => deleteNestedProperty(contentFile, pattern)); - fs.writeFileSync(filePath, JSON.stringify(contentFile)); - } + const contentFile = JSON.parse(fs.readFileSync(filePath, "utf8")); + patterns.forEach((pattern) => deleteNestedProperty(contentFile, pattern)); + fs.writeFileSync(filePath, JSON.stringify(contentFile)); } function deleteNestedProperty(obj, propertyPath) { diff --git a/src/tailwind-plugin/tw-theme.js b/src/tailwind-plugin/tw-theme.js index f1b872f..751b8fa 100644 --- a/src/tailwind-plugin/tw-theme.js +++ b/src/tailwind-plugin/tw-theme.js @@ -47,8 +47,22 @@ module.exports = plugin.withOptions(() => { const groups = [ { colors: themeConfig.colors.default.theme_color, prefix: "" }, { colors: themeConfig.colors.default.text_color, prefix: "" }, - { colors: themeConfig.colors.darkmode.theme_color, prefix: "darkmode-" }, - { colors: themeConfig.colors.darkmode.text_color, prefix: "darkmode-" }, + ...(themeConfig.colors.darkmode?.theme_color + ? [ + { + colors: themeConfig.colors.darkmode.theme_color, + prefix: "darkmode-", + }, + ] + : []), + ...(themeConfig.colors.darkmode?.text_color + ? [ + { + colors: themeConfig.colors.darkmode.text_color, + prefix: "darkmode-", + }, + ] + : []), ]; // Set color variables