@tok124/tokcss 1.0.0 → 1.0.1
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 +101 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# tokcss
|
|
2
|
+
|
|
3
|
+
A stupidly simple CSS "preprocessor" with exactly one directive:
|
|
4
|
+
|
|
5
|
+
```css
|
|
6
|
+
#include:"path/to/file.css";
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
That's it. No variables, no nesting, no mixins — just includes, like SCSS's
|
|
10
|
+
`@use` but with a single directive and zero other opinions. If you just want
|
|
11
|
+
`@import` without the "browsers deprecated it, please don't" baggage, this is
|
|
12
|
+
for you.
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install -g @tok124/tokcss
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Or run it without installing:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npx @tok124/tokcss entry.tokcss -o out.css
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
tokcss entry.tokcss # prints result to stdout
|
|
30
|
+
tokcss entry.tokcss -o out.css # writes result to out.css
|
|
31
|
+
tokcss entry.tokcss -o out.css -w # watches all included files, recompiles on change
|
|
32
|
+
tokcss entry.tokcss -o out.css --no-banner # omit the "/* --- from: ... --- */" source markers
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`-w` / `--watch` re-scans the include tree after every rebuild, so adding or
|
|
36
|
+
removing `#include` lines updates what's being watched too.
|
|
37
|
+
|
|
38
|
+
## Includes
|
|
39
|
+
|
|
40
|
+
Paths are resolved relative to the file containing the `#include`, so nested
|
|
41
|
+
folders work as expected:
|
|
42
|
+
|
|
43
|
+
```css
|
|
44
|
+
/* main.tokcss */
|
|
45
|
+
#include:"reset.css";
|
|
46
|
+
#include:"components/button.css";
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Including the same file twice (directly or via a cycle) only inlines it
|
|
50
|
+
once — later duplicates are skipped, like `@use`.
|
|
51
|
+
|
|
52
|
+
## Conditional includes
|
|
53
|
+
|
|
54
|
+
`#include` accepts the same trailing conditions as native `@import`: cascade
|
|
55
|
+
layers, `@supports` conditions, and media queries. Combine them freely, in
|
|
56
|
+
any order:
|
|
57
|
+
|
|
58
|
+
```css
|
|
59
|
+
#include:"reset.css" layer(reset);
|
|
60
|
+
#include:"grid.css" supports(display: grid);
|
|
61
|
+
#include:"wide.css" (width >= 50rem);
|
|
62
|
+
#include:"a.css" layer(base) supports(display: grid) (min-width: 500px);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Each one wraps the included file's compiled output in the matching
|
|
66
|
+
`@layer` / `@supports` / `@media` block (nested in that order), indented for
|
|
67
|
+
readability:
|
|
68
|
+
|
|
69
|
+
```css
|
|
70
|
+
@layer base {
|
|
71
|
+
@supports (display: grid) {
|
|
72
|
+
@media (min-width: 500px) {
|
|
73
|
+
/* contents of a.css */
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
A bare `layer;` with no name creates an anonymous layer, same as `@import`.
|
|
80
|
+
|
|
81
|
+
## VSCode syntax highlighting
|
|
82
|
+
|
|
83
|
+
`.tokcss` files are just CSS with one extra directive, so rather than writing
|
|
84
|
+
a custom grammar, tell VSCode to treat them as CSS. Add this to your
|
|
85
|
+
`settings.json` (Command Palette → "Preferences: Open User Settings (JSON)"):
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"files.associations": {
|
|
90
|
+
"*.tokcss": "css"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
You get full CSS highlighting, IntelliSense, and color previews. The
|
|
96
|
+
`#include:"...";` line itself won't be specially highlighted, but it won't
|
|
97
|
+
break anything either.
|
|
98
|
+
|
|
99
|
+
## License
|
|
100
|
+
|
|
101
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tok124/tokcss",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "A stupidly simple CSS preprocessor with one directive: #include:\"file.css\"; — optionally wrapped in @layer/@supports/@media, just like @import.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"tokcss": "tokcss.js"
|