Home

tailwind-ctp-intellisense @master - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tree log patch
fix JIT initialisation when mode is set in a preset (fixes #333)
Brad Cornes <bradlc41@gmail.com>
3 years ago
1 changed files, 43 additions(+), 4 deletions(-)
M src/server.ts -> src/server.ts
diff --git a/src/server.ts b/src/server.ts
index d989855fee7e6702793983f14d3e637f6020c9c0..caba364db4cd3b990d0e51aa6d7c2f02c2baea81 100644
--- a/src/server.ts
+++ b/src/server.ts
@@ -577,6 +577,9 @@     let userPurge
     let userVariants: any
     let userMode: any
     let userPlugins: any
+    let presetModes: any[] = []
+    let presetVariants: any[] = []
+
     let hook = new Hook(fs.realpathSync(state.configPath), (exports) => {
       userSeperator = dlv(exports, sepLocation)
       if (typeof userSeperator !== 'string') {
@@ -589,16 +592,37 @@         sepLocation,
         `__TWSEP__${typeof userSeperator === 'undefined' ? ':' : userSeperator}__TWSEP__`
       )
       exports.purge = []
-      if (state.modules.jit && exports.mode === 'jit') {
+
+      let mode: any
+      if (Array.isArray(exports.presets)) {
+        for (let preset of exports.presets) {
+          if (typeof preset.mode !== 'undefined') {
+            mode = preset.mode
+          }
+          presetModes.push(preset.mode)
+          delete preset.mode
+        }
+      }
+      if (typeof exports.mode !== 'undefined') {
+        mode = exports.mode
+      }
+      userMode = exports.mode
+      delete exports.mode
+
+      if (state.modules.jit && mode === 'jit') {
         state.jit = true
         userVariants = exports.variants
         exports.variants = []
+
+        if (Array.isArray(exports.presets)) {
+          for (let preset of exports.presets) {
+            presetVariants.push(preset.variants)
+            preset.variants = []
+          }
+        }
       } else {
         state.jit = false
       }
-
-      userMode = exports.mode
-      delete exports.mode
 
       // inject JIT `matchUtilities` function
       if (Array.isArray(exports.plugins)) {
@@ -700,6 +724,21 @@       config.mode = userMode
     }
     if (typeof userPlugins !== 'undefined') {
       config.plugins = userPlugins
+    }
+
+    for (let index in presetModes) {
+      if (typeof presetModes[index] === 'undefined') {
+        delete config.presets[index].mode
+      } else {
+        config.presets[index].mode = presetModes[index]
+      }
+    }
+    for (let index in presetVariants) {
+      if (typeof presetVariants[index] === 'undefined') {
+        delete config.presets[index].variants
+      } else {
+        config.presets[index].variants = presetVariants[index]
+      }
     }
 
     if (state.dependencies) {