anubis-ui 1.2.5 → 1.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,9 +7,7 @@ AnubisUI (Autonomous Nominative Utility Based Intuitive Styler) is a Vite plugin
7
7
  > <br />
8
8
  > Classes must be EXPLICITY written in the code to allow the extraction to work correctly, dynamic classes will not work
9
9
  > <br />
10
- > In the future, some config will allow to generate a bunch of specified classes even if not present in the code
11
- > <br />
12
- > Until then, you can create a decoy .vue file filled with the dynamic classes you want
10
+ > You can use the `force` configuration to generate specific classes even if they're not present in the code
13
11
  > <br />
14
12
 
15
13
  ## Table of Contents
@@ -167,6 +165,13 @@ For every config you want to change, add the corresponding section in your confi
167
165
  "thin": "2px"
168
166
  }
169
167
  }
168
+ ],
169
+
170
+ // force.config.json
171
+ "force": [
172
+ "bg-primary-10",
173
+ "bg-primary-20",
174
+ "bg-primary-30"
170
175
  ]
171
176
  }
172
177
  ```
@@ -342,6 +347,29 @@ Example usage:
342
347
  <div class="rounded smooth" /> <!-- Works because these are standalone -->
343
348
  ```
344
349
 
350
+ ### Force (`force.config.json`)
351
+ Force the generation of specific CSS classes even if they're not found in your code. This is particularly useful for dynamic classes that can't be detected during the extraction process.
352
+
353
+ <details>
354
+ <summary>Default config</summary>
355
+
356
+ ```json
357
+ []
358
+ ```
359
+ </details>
360
+
361
+ Example usage:
362
+ ```json
363
+ {
364
+ "force": [
365
+ "bg-primary-10",
366
+ "bg-primary-20",
367
+ "bg-primary-30",
368
+ "hover:bg-secondary-50"
369
+ ]
370
+ }
371
+ ```
372
+
345
373
  ## Available Utility Classes
346
374
  #### Colors
347
375
  - `bg-{color}` - Background color
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anubis-ui",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
4
4
  "description": "Class-based css generator",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -9,6 +9,7 @@ const anubisConfigFolder = path.join(__dirname, '..', '..', 'src', 'config');
9
9
  const anubisConfigFiles = [
10
10
  'qol',
11
11
  'files',
12
+ 'force',
12
13
  'colors',
13
14
  'states',
14
15
  'presets',
@@ -18,6 +19,9 @@ const config = {
18
19
  qol: [],
19
20
  presets: [],
20
21
 
22
+ /** User-given classes to force the css rule creation */
23
+ force: [],
24
+
21
25
  files: { targets: [], ignore: [] },
22
26
  colors: [],
23
27
  states: [],
@@ -37,6 +41,7 @@ const init = () => {
37
41
  } else {
38
42
  const filePath = path.join(anubisConfigFolder, `${file}.config.json`)
39
43
  const configContent = fs.readFileSync(filePath, { encoding: 'utf-8' })
44
+ if (!configContent) { continue }
40
45
 
41
46
  configToUse = JSON.parse(configContent)
42
47
  }
@@ -22,9 +22,10 @@ const getUniqueClasses = async (files: string[]): Promise<string[]> => {
22
22
  files.map(async file => extractClasses(file))
23
23
  ))
24
24
  ?.flat()
25
- ?.sort()
26
25
 
27
- const uniqueClasses = Array.from(new Set(extractedClasses))
26
+ const classes = [...extractedClasses, ...config.force]?.sort()
27
+
28
+ const uniqueClasses = Array.from(new Set(classes))
28
29
  return uniqueClasses
29
30
  }
30
31