@unizap/unicss 2.0.8 → 2.0.10

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/LICENSE CHANGED
@@ -1,9 +1,9 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Your Name
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
-
7
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
-
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Your Name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
9
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,168 +1,168 @@
1
- <p></p>
2
- <p align="center">
3
- <img src="https://ik.imagekit.io/unizap/unicss_logo.svg" alt="UniCSS Logo" height="80"/>
4
- </p>
5
-
6
-
7
- <p align="center">
8
- <b>Build sleek interfaces straight from your markup.<br>
9
- Fast, modern, utility-first CSS framework for rapid UI development.</b>
10
- </p>
11
-
12
- ---
13
-
14
- ## 🚀 Installation
15
-
16
- ```sh
17
- npm i @unizap/unicss
18
- ```
19
-
20
- ---
21
-
22
- ## ⚡ Usage
23
-
24
- ### CLI Usage
25
-
26
- Generate your CSS file:
27
-
28
- ```sh
29
- npx unicss
30
- ```
31
-
32
- Or watch for changes and output to a custom file:
33
-
34
- ```sh
35
- npx unicss -w -o src/output.css
36
- ```
37
-
38
- ### Vite Integration
39
-
40
- UniCSS now supports seamless integration with Vite! Add the plugin to your `vite.config.js`:
41
-
42
- ```js
43
- import { defineConfig } from 'vite';
44
- import unicss from '@unizap/unicss/vite-plugin-unicss';
45
-
46
- export default defineConfig({
47
- plugins: [
48
- unicss({
49
- output: 'src/unicss.css', // Output path for generated CSS
50
- skipBase: false // Optional: skip base styles
51
- })
52
- ]
53
- });
54
- ```
55
-
56
- Then import the generated CSS in your main entry file:
57
-
58
- ```js
59
- import './unicss.css';
60
- ```
61
-
62
- Run Vite in development mode:
63
-
64
- ```sh
65
- npm run dev
66
- ```
67
-
68
- The plugin will:
69
- - Automatically scan all `.html`, `.js`, `.jsx`, `.ts`, `.tsx`, `.vue`, and `.svelte` files
70
- - Generate CSS based on the utility classes found
71
- - Regenerate CSS on file changes with Hot Module Replacement (HMR)
72
-
73
- ### PostCSS Integration (Recommended)
74
-
75
- UniCSS works seamlessly with PostCSS, similar to Tailwind CSS. This is the recommended approach for modern web applications.
76
-
77
- #### Method 1: Using @unicss Directives (Like Tailwind)
78
-
79
- Create a CSS file with UniCSS directives:
80
-
81
- ```css
82
- /* app/globals.css or src/styles.css */
83
- @unicss;
84
- ```
85
-
86
- Configure PostCSS in your project:
87
-
88
- ```js
89
- // postcss.config.js
90
- module.exports = {
91
- plugins: {
92
- '@unizap/unicss/postcss': {},
93
- autoprefixer: {}
94
- }
95
- }
96
- ```
97
-
98
- Import the CSS in your application:
99
-
100
- ```js
101
- // For Next.js, Vite, or other frameworks
102
- import './globals.css'
103
- ```
104
-
105
- The `@unicss` directive will be replaced with all generated utility classes. You can also split base and utilities:
106
-
107
- ```css
108
- @unicss base; /* Base styles and resets */
109
- @unicss utilities; /* Utility classes only */
110
- ```
111
-
112
- #### Method 2: Use the Included PostCSS Config
113
-
114
- UniCSS includes a ready-to-use PostCSS configuration with these plugins:
115
- - `@unizap/unicss/postcss` - Generate UniCSS utilities
116
- - `postcss-import` - Inline @import rules
117
- - `postcss-nested` - Unwrap nested rules
118
- - `autoprefixer` - Add vendor prefixes automatically
119
-
120
- Import it directly:
121
-
122
- ```js
123
- // postcss.config.js
124
- const unicssPostCSS = require('@unizap/unicss/postcss.config.js');
125
- module.exports = unicssPostCSS;
126
- ```
127
-
128
- ---
129
-
130
- ## 🧩 Features
131
-
132
- - Utility-first CSS generator
133
- - PostCSS plugin with @unicss directives (like Tailwind)
134
- - Automatic CSS filter utilities (e.g. `blur-lg`, `brightness-150`)
135
- - Fast, modern, and easy to integrate
136
- - Supports custom output paths and watch mode
137
- - Vite plugin for seamless integration
138
- - Works with Next.js, Remix, Astro, and any PostCSS-based setup
139
- - Hot module replacement (HMR) in development
140
-
141
- ---
142
-
143
- ## 🔧 Development & Publishing
144
-
145
- ### Building the package
146
-
147
- ```sh
148
- npm run build
149
- ```
150
-
151
- This creates:
152
- - `dist/index.js` - Node.js bundle for CLI
153
- - `dist/unicss.min.js` - Browser CDN bundle
154
-
155
- ### Publishing to npm
156
-
157
- ```sh
158
- npm run build
159
- npm publish
160
- ```
161
-
162
- See [PUBLISHING.md](./PUBLISHING.md) for detailed instructions.
163
-
164
- ---
165
-
166
- ## 📄 License
167
-
1
+ <p></p>
2
+ <p align="center">
3
+ <img src="https://ik.imagekit.io/unizap/unicss_logo.svg" alt="UniCSS Logo" height="80"/>
4
+ </p>
5
+
6
+
7
+ <p align="center">
8
+ <b>Build sleek interfaces straight from your markup.<br>
9
+ Fast, modern, utility-first CSS framework for rapid UI development.</b>
10
+ </p>
11
+
12
+ ---
13
+
14
+ ## 🚀 Installation
15
+
16
+ ```sh
17
+ npm i @unizap/unicss
18
+ ```
19
+
20
+ ---
21
+
22
+ ## ⚡ Usage
23
+
24
+ ### CLI Usage
25
+
26
+ Generate your CSS file:
27
+
28
+ ```sh
29
+ npx unicss
30
+ ```
31
+
32
+ Or watch for changes and output to a custom file:
33
+
34
+ ```sh
35
+ npx unicss -w -o src/output.css
36
+ ```
37
+
38
+ ### Vite Integration
39
+
40
+ UniCSS now supports seamless integration with Vite! Add the plugin to your `vite.config.js`:
41
+
42
+ ```js
43
+ import { defineConfig } from 'vite';
44
+ import unicss from '@unizap/unicss/vite-plugin-unicss';
45
+
46
+ export default defineConfig({
47
+ plugins: [
48
+ unicss({
49
+ output: 'src/unicss.css', // Output path for generated CSS
50
+ skipBase: false // Optional: skip base styles
51
+ })
52
+ ]
53
+ });
54
+ ```
55
+
56
+ Then import the generated CSS in your main entry file:
57
+
58
+ ```js
59
+ import './unicss.css';
60
+ ```
61
+
62
+ Run Vite in development mode:
63
+
64
+ ```sh
65
+ npm run dev
66
+ ```
67
+
68
+ The plugin will:
69
+ - Automatically scan all `.html`, `.js`, `.jsx`, `.ts`, `.tsx`, `.vue`, and `.svelte` files
70
+ - Generate CSS based on the utility classes found
71
+ - Regenerate CSS on file changes with Hot Module Replacement (HMR)
72
+
73
+ ### PostCSS Integration (Recommended)
74
+
75
+ UniCSS works seamlessly with PostCSS, similar to Tailwind CSS. This is the recommended approach for modern web applications.
76
+
77
+ #### Method 1: Using @unicss Directives (Like Tailwind)
78
+
79
+ Create a CSS file with UniCSS directives:
80
+
81
+ ```css
82
+ /* app/globals.css or src/styles.css */
83
+ @unicss;
84
+ ```
85
+
86
+ Configure PostCSS in your project:
87
+
88
+ ```js
89
+ // postcss.config.js
90
+ module.exports = {
91
+ plugins: {
92
+ '@unizap/unicss/postcss': {},
93
+ autoprefixer: {}
94
+ }
95
+ }
96
+ ```
97
+
98
+ Import the CSS in your application:
99
+
100
+ ```js
101
+ // For Next.js, Vite, or other frameworks
102
+ import './globals.css'
103
+ ```
104
+
105
+ The `@unicss` directive will be replaced with all generated utility classes. You can also split base and utilities:
106
+
107
+ ```css
108
+ @unicss base; /* Base styles and resets */
109
+ @unicss utilities; /* Utility classes only */
110
+ ```
111
+
112
+ #### Method 2: Use the Included PostCSS Config
113
+
114
+ UniCSS includes a ready-to-use PostCSS configuration with these plugins:
115
+ - `@unizap/unicss/postcss` - Generate UniCSS utilities
116
+ - `postcss-import` - Inline @import rules
117
+ - `postcss-nested` - Unwrap nested rules
118
+ - `autoprefixer` - Add vendor prefixes automatically
119
+
120
+ Import it directly:
121
+
122
+ ```js
123
+ // postcss.config.js
124
+ const unicssPostCSS = require('@unizap/unicss/postcss.config.js');
125
+ module.exports = unicssPostCSS;
126
+ ```
127
+
128
+ ---
129
+
130
+ ## 🧩 Features
131
+
132
+ - Utility-first CSS generator
133
+ - PostCSS plugin with @unicss directives (like Tailwind)
134
+ - Automatic CSS filter utilities (e.g. `blur-lg`, `brightness-150`)
135
+ - Fast, modern, and easy to integrate
136
+ - Supports custom output paths and watch mode
137
+ - Vite plugin for seamless integration
138
+ - Works with Next.js, Remix, Astro, and any PostCSS-based setup
139
+ - Hot module replacement (HMR) in development
140
+
141
+ ---
142
+
143
+ ## 🔧 Development & Publishing
144
+
145
+ ### Building the package
146
+
147
+ ```sh
148
+ npm run build
149
+ ```
150
+
151
+ This creates:
152
+ - `dist/index.js` - Node.js bundle for CLI
153
+ - `dist/unicss.min.js` - Browser CDN bundle
154
+
155
+ ### Publishing to npm
156
+
157
+ ```sh
158
+ npm run build
159
+ npm publish
160
+ ```
161
+
162
+ See [PUBLISHING.md](./PUBLISHING.md) for detailed instructions.
163
+
164
+ ---
165
+
166
+ ## 📄 License
167
+
168
168
  MIT
package/bin/index.js CHANGED
@@ -1,56 +1,56 @@
1
- #!/usr/bin/env node
2
-
3
- const path = require("path");
4
- const fs = require("fs");
5
- const generateCSS = require("../dist/index.js");
6
-
7
- const args = process.argv.slice(2);
8
- let outFile = "style/unicss.css";
9
- let watch = false;
10
- let skipBase = false;
11
- let content = null;
12
-
13
- for (let i = 0; i < args.length; i++) {
14
- if ((args[i] === "-o" || args[i] === "--output") && args[i + 1]) {
15
- outFile = args[i + 1];
16
- i++;
17
- }
18
- if (args[i] === "-w" || args[i] === "--watch") {
19
- watch = true;
20
- }
21
- if (args[i] === "--skip-base") {
22
- skipBase = true;
23
- }
24
- if ((args[i] === "-c" || args[i] === "--content") && args[i + 1]) {
25
- // Support multiple patterns separated by comma or multiple --content flags
26
- const patterns = args[i + 1].split(",").map(p => p.trim());
27
- content = content ? [...content, ...patterns] : patterns;
28
- i++;
29
- }
30
- }
31
-
32
- function run() {
33
- const css = generateCSS({ skipBase, content });
34
- const outDir = path.dirname(outFile);
35
- if (!fs.existsSync(outDir)) {
36
- fs.mkdirSync(outDir, { recursive: true });
37
- }
38
- fs.writeFileSync(outFile, css);
39
- console.log(`Unicss generated at ${outFile}`);
40
- }
41
-
42
- run();
43
-
44
- if (watch) {
45
- const chokidar = require("chokidar");
46
- // Watch content patterns or default patterns, plus the config
47
- const watchPatterns = content || ["**/*.{js,jsx,ts,tsx,html,vue}"];
48
- const watcher = chokidar.watch([
49
- ...watchPatterns,
50
- "unicss.config.js"
51
- ], { ignoreInitial: true });
52
- watcher.on("all", () => {
53
- console.log("Change detected. Regenerating Unicss...");
54
- run();
55
- });
1
+ #!/usr/bin/env node
2
+
3
+ const path = require("path");
4
+ const fs = require("fs");
5
+ const generateCSS = require("../dist/index.js");
6
+
7
+ const args = process.argv.slice(2);
8
+ let outFile = "style/unicss.css";
9
+ let watch = false;
10
+ let skipBase = false;
11
+ let content = null;
12
+
13
+ for (let i = 0; i < args.length; i++) {
14
+ if ((args[i] === "-o" || args[i] === "--output") && args[i + 1]) {
15
+ outFile = args[i + 1];
16
+ i++;
17
+ }
18
+ if (args[i] === "-w" || args[i] === "--watch") {
19
+ watch = true;
20
+ }
21
+ if (args[i] === "--skip-base") {
22
+ skipBase = true;
23
+ }
24
+ if ((args[i] === "-c" || args[i] === "--content") && args[i + 1]) {
25
+ // Support multiple patterns separated by comma or multiple --content flags
26
+ const patterns = args[i + 1].split(",").map(p => p.trim());
27
+ content = content ? [...content, ...patterns] : patterns;
28
+ i++;
29
+ }
30
+ }
31
+
32
+ function run() {
33
+ const css = generateCSS({ skipBase, content });
34
+ const outDir = path.dirname(outFile);
35
+ if (!fs.existsSync(outDir)) {
36
+ fs.mkdirSync(outDir, { recursive: true });
37
+ }
38
+ fs.writeFileSync(outFile, css);
39
+ console.log(`Unicss generated at ${outFile}`);
40
+ }
41
+
42
+ run();
43
+
44
+ if (watch) {
45
+ const chokidar = require("chokidar");
46
+ // Watch content patterns or default patterns, plus the config
47
+ const watchPatterns = content || ["**/*.{js,jsx,ts,tsx,html,vue}"];
48
+ const watcher = chokidar.watch([
49
+ ...watchPatterns,
50
+ "unicss.config.js"
51
+ ], { ignoreInitial: true });
52
+ watcher.on("all", () => {
53
+ console.log("Change detected. Regenerating Unicss...");
54
+ run();
55
+ });
56
56
  }