strata-css 1.0.1 → 1.0.2
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/bin/strata.js +62 -24
- package/package.json +1 -1
- package/src/index.js +11 -12
package/bin/strata.js
CHANGED
|
@@ -11,9 +11,19 @@ const { getWatchFiles } = require('../src/scanner/scanner')
|
|
|
11
11
|
const args = process.argv.slice(2)
|
|
12
12
|
const cwd = process.cwd()
|
|
13
13
|
|
|
14
|
-
function loadConfig() {
|
|
15
|
-
const configPath
|
|
16
|
-
|
|
14
|
+
function loadConfig(cwd) {
|
|
15
|
+
const configPath = path.resolve(cwd, 'strata.config.js')
|
|
16
|
+
const configPathCjs = path.resolve(cwd, 'strata.config.cjs')
|
|
17
|
+
|
|
18
|
+
if (fs.existsSync(configPathCjs)) {
|
|
19
|
+
try { return require(configPathCjs) } catch {}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (fs.existsSync(configPath)) {
|
|
23
|
+
try { return require(configPath) } catch {}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return {}
|
|
17
27
|
}
|
|
18
28
|
|
|
19
29
|
// ─── JS minifier ──────────────────────────────────────────────────────
|
|
@@ -38,7 +48,7 @@ function minifyJS(src) {
|
|
|
38
48
|
// --minify → minified CSS + minified JS (smallest possible output)
|
|
39
49
|
|
|
40
50
|
async function build(cssMinify = false, jsMinify = true) {
|
|
41
|
-
const config = loadConfig()
|
|
51
|
+
const config = loadConfig(cwd)
|
|
42
52
|
const inputFile = config.input || path.join(cwd, 'strata.css')
|
|
43
53
|
const outputFile = config.output || path.join(cwd, 'dist', 'strata.output.css')
|
|
44
54
|
|
|
@@ -78,7 +88,7 @@ async function watch() {
|
|
|
78
88
|
console.log('[Strata] Starting in watch mode...')
|
|
79
89
|
await build(false, false) // unminified for dev
|
|
80
90
|
|
|
81
|
-
const config = loadConfig()
|
|
91
|
+
const config = loadConfig(cwd)
|
|
82
92
|
const contentGlobs = config.content || ['./src/**/*.{html,jsx,tsx,vue,astro,svelte,js,ts}']
|
|
83
93
|
const inputFile = config.input || path.join(cwd, 'strata.css')
|
|
84
94
|
const watchFiles = [inputFile, ...getWatchFiles(contentGlobs)]
|
|
@@ -100,28 +110,56 @@ async function watch() {
|
|
|
100
110
|
console.log('[Strata] Watching for changes...')
|
|
101
111
|
}
|
|
102
112
|
|
|
103
|
-
// ───
|
|
104
|
-
function
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
'postcss.config.js':`module.exports = { plugins: [require('strata-css'), require('autoprefixer')] }\n`,
|
|
113
|
+
// ─── ESM / framework helpers ──────────────────────────────────────────
|
|
114
|
+
function isESMProject(cwd) {
|
|
115
|
+
try {
|
|
116
|
+
const pkg = JSON.parse(fs.readFileSync(path.resolve(cwd, 'package.json'), 'utf8'))
|
|
117
|
+
return pkg.type === 'module'
|
|
118
|
+
} catch {
|
|
119
|
+
return false
|
|
111
120
|
}
|
|
121
|
+
}
|
|
112
122
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
123
|
+
function detectOutputPath(cwd) {
|
|
124
|
+
try {
|
|
125
|
+
const pkg = JSON.parse(fs.readFileSync(path.resolve(cwd, 'package.json'), 'utf8'))
|
|
126
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies }
|
|
127
|
+
if (deps['astro']) return './public/strata.output.css'
|
|
128
|
+
if (deps['laravel-vite-plugin']) return './public/strata.output.css'
|
|
129
|
+
if (deps['next']) return './public/strata.output.css'
|
|
130
|
+
if (deps['react']) return './public/strata.output.css'
|
|
131
|
+
if (deps['vue']) return './public/strata.output.css'
|
|
132
|
+
if (deps['@sveltejs/kit']) return './public/strata.output.css'
|
|
133
|
+
} catch {}
|
|
134
|
+
return './dist/strata.output.css'
|
|
135
|
+
}
|
|
122
136
|
|
|
123
|
-
|
|
124
|
-
|
|
137
|
+
// ─── Init ─────────────────────────────────────────────────────────────
|
|
138
|
+
function init() {
|
|
139
|
+
const isESM = isESMProject(cwd)
|
|
140
|
+
const output = detectOutputPath(cwd)
|
|
141
|
+
|
|
142
|
+
console.log('[Strata] Initializing project...')
|
|
143
|
+
console.log(`[Strata] Detected: ${isESM ? 'ESM' : 'CommonJS'} project`)
|
|
144
|
+
|
|
145
|
+
const configFile = isESM ? 'strata.config.cjs' : 'strata.config.js'
|
|
146
|
+
const postcssFile = isESM ? 'postcss.config.cjs' : 'postcss.config.js'
|
|
147
|
+
|
|
148
|
+
const configContent = `module.exports = {\n content: ["./src/**/*.{html,jsx,tsx,vue,astro,svelte,js,ts}"],\n input: "./strata.css",\n output: "${output}"\n}\n`
|
|
149
|
+
const postcssContent = `module.exports = {\n plugins: [\n require('strata-css'),\n require('autoprefixer')\n ]\n}\n`
|
|
150
|
+
const strataCssContent = `@strata base;\n@strata components;\n@strata utilities;\n`
|
|
151
|
+
|
|
152
|
+
fs.writeFileSync(path.resolve(cwd, configFile), configContent)
|
|
153
|
+
fs.writeFileSync(path.resolve(cwd, postcssFile), postcssContent)
|
|
154
|
+
fs.writeFileSync(path.resolve(cwd, 'strata.css'), strataCssContent)
|
|
155
|
+
|
|
156
|
+
console.log(`[Strata] Created: ${configFile}`)
|
|
157
|
+
console.log(`[Strata] Created: strata.css`)
|
|
158
|
+
console.log(`[Strata] Created: ${postcssFile}`)
|
|
159
|
+
console.log(`[Strata] Done! Next steps:`)
|
|
160
|
+
console.log(`[Strata] 1. Add <link rel="stylesheet" href="/strata.output.css"> to your HTML`)
|
|
161
|
+
console.log(`[Strata] 2. Add data-st-theme="light" to your <html> tag`)
|
|
162
|
+
console.log(`[Strata] 3. Run: node node_modules/strata-css/bin/strata.js --build`)
|
|
125
163
|
}
|
|
126
164
|
|
|
127
165
|
// ─── Run ──────────────────────────────────────────────────────────────
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strata-css",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"_versioningNote": "Stable: 1.0.0 / 1.1.0 / 2.0.0 | Beta: 1.1.0-beta.1 / 1.1.0-beta.2",
|
|
5
5
|
"description": "A modern CSS framework combining Bootstrap components with Tailwind JIT processing",
|
|
6
6
|
"main": "src/index.js",
|
package/src/index.js
CHANGED
|
@@ -22,19 +22,18 @@ let cachedConfigPath = null
|
|
|
22
22
|
let cachedConfigMtime = 0
|
|
23
23
|
|
|
24
24
|
function loadConfig(cwd) {
|
|
25
|
-
const configPath
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (
|
|
29
|
-
return
|
|
25
|
+
const configPath = path.resolve(cwd, 'strata.config.js')
|
|
26
|
+
const configPathCjs = path.resolve(cwd, 'strata.config.cjs')
|
|
27
|
+
|
|
28
|
+
if (fs.existsSync(configPathCjs)) {
|
|
29
|
+
try { return require(configPathCjs) } catch {}
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return cachedConfig
|
|
31
|
+
|
|
32
|
+
if (fs.existsSync(configPath)) {
|
|
33
|
+
try { return require(configPath) } catch {}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return {}
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
// ─── Base CSS ─────────────────────────────────────────────────────────
|