@gustcss/postcss 0.3.2 → 0.5.0
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/index.js +23 -5
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { spawnSync } = require('child_process')
|
|
2
2
|
const path = require('path')
|
|
3
3
|
const fs = require('fs')
|
|
4
4
|
|
|
@@ -20,6 +20,7 @@ const fs = require('fs')
|
|
|
20
20
|
module.exports = (opts = {}) => {
|
|
21
21
|
const content = opts.content || ['./src/**/*.{js,ts,jsx,tsx}']
|
|
22
22
|
const configPath = opts.config
|
|
23
|
+
const outputToCssLayers = opts.outputToCssLayers
|
|
23
24
|
|
|
24
25
|
return {
|
|
25
26
|
postcssPlugin: 'gustcss',
|
|
@@ -57,6 +58,11 @@ module.exports = (opts = {}) => {
|
|
|
57
58
|
// Build CLI arguments
|
|
58
59
|
const args = ['build', '--stdout']
|
|
59
60
|
|
|
61
|
+
// Add --css-layers flag if enabled
|
|
62
|
+
if (outputToCssLayers) {
|
|
63
|
+
args.push('--css-layers')
|
|
64
|
+
}
|
|
65
|
+
|
|
60
66
|
// Determine config file path
|
|
61
67
|
let resolvedConfigPath = configPath
|
|
62
68
|
if (!resolvedConfigPath) {
|
|
@@ -88,19 +94,31 @@ module.exports = (opts = {}) => {
|
|
|
88
94
|
}
|
|
89
95
|
|
|
90
96
|
try {
|
|
91
|
-
const
|
|
97
|
+
const result = spawnSync(binaryPath, args, {
|
|
92
98
|
cwd,
|
|
93
99
|
encoding: 'utf-8',
|
|
94
100
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
95
101
|
})
|
|
96
102
|
|
|
103
|
+
if (result.status !== 0) {
|
|
104
|
+
throw new Error(`gustcss build failed: ${result.stderr}`)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Output generation time log from stderr
|
|
108
|
+
if (result.stderr) {
|
|
109
|
+
process.stderr.write(result.stderr)
|
|
110
|
+
}
|
|
111
|
+
|
|
97
112
|
// Parse the generated CSS and append to the root
|
|
98
113
|
const postcss = require('postcss')
|
|
99
|
-
const parsed = postcss.parse(
|
|
114
|
+
const parsed = postcss.parse(result.stdout)
|
|
100
115
|
root.append(parsed)
|
|
101
116
|
} catch (error) {
|
|
102
|
-
|
|
103
|
-
|
|
117
|
+
// CLI build failures (status !== 0) are already thrown above with stderr details.
|
|
118
|
+
// This catch block handles other errors:
|
|
119
|
+
// - spawnSync failures (e.g., binary not found, spawn error)
|
|
120
|
+
// - postcss.parse errors (malformed CSS output)
|
|
121
|
+
throw new Error(`gustcss build failed: ${error.message}`)
|
|
104
122
|
} finally {
|
|
105
123
|
// Clean up temporary config file
|
|
106
124
|
if (tempConfigPath && fs.existsSync(tempConfigPath)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gustcss/postcss",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "PostCSS plugin for GustCSS",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"gustcss": "^0.
|
|
15
|
+
"gustcss": "^0.5.0"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"postcss": "^8.0.0"
|