@gustcss/postcss 0.9.2 → 0.10.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/README.md CHANGED
@@ -70,6 +70,12 @@ Create `gustcss.config.json` in your project root:
70
70
  }
71
71
  ```
72
72
 
73
+ ### Class-Name Mangling
74
+
75
+ The PostCSS plugin does not support `mangleClassNames` because PostCSS cannot rewrite HTML and JavaScript references to match shortened CSS selectors.
76
+
77
+ The plugin explicitly disables config-based mangling. Use `@gustcss/vite` for synchronized production CSS and source transformation.
78
+
73
79
  ## How It Works
74
80
 
75
81
  1. The plugin scans files specified in the `content` array
package/dist/index.cjs CHANGED
@@ -61,6 +61,24 @@ var require_runner = /* @__PURE__ */ __commonJSMin(((exports, module) => {
61
61
  return null;
62
62
  }
63
63
  /**
64
+ * Report whether a resolved gustcss.config.json turns on class-name mangling.
65
+ *
66
+ * Callers that cannot rewrite source (dev server, PostCSS) use this to decide
67
+ * whether they must pass `--mangle-class-names=false`. Only passing the flag
68
+ * when needed keeps older CLI binaries that predate the flag working.
69
+ *
70
+ * @param {{ configPath: string|null, fs?: { readFileSync: Function } }} options
71
+ * @returns {boolean}
72
+ */
73
+ function configEnablesMangling({ configPath, fs = require("fs") }) {
74
+ if (!configPath) return false;
75
+ try {
76
+ return JSON.parse(fs.readFileSync(configPath, "utf-8"))?.mangleClassNames === true;
77
+ } catch {
78
+ return false;
79
+ }
80
+ }
81
+ /**
64
82
  * Write a temporary config file ({ content }) at <cwd>/<prefix>.<random8hex>.tmp.json,
65
83
  * invoke `fn` with the temp file path, and always clean the file up afterwards.
66
84
  *
@@ -92,21 +110,28 @@ var require_runner = /* @__PURE__ */ __commonJSMin(((exports, module) => {
92
110
  * @param {string} [options.output] output path (required for 'output' mode)
93
111
  * @param {boolean} [options.cssLayers] append --css-layers when truthy
94
112
  * @param {boolean} [options.watch] append --watch when truthy
113
+ * @param {boolean} [options.mangleClassNames] explicitly enable or disable mangling
114
+ * @param {string} [options.mangleMap] class-name manifest output path
115
+ * @param {string[]} [options.mangleExclude] class names to preserve
95
116
  * @param {string|null} [options.configPath] append --config <path> when present
96
117
  * @returns {string[]}
97
118
  */
98
- function buildArgs({ mode, output, cssLayers, configPath, watch }) {
119
+ function buildArgs({ mode, output, cssLayers, configPath, watch, mangleClassNames, mangleMap, mangleExclude }) {
99
120
  const args = ["build"];
100
121
  if (watch) args.push("--watch");
101
122
  if (mode === "stdout") args.push("--stdout");
102
123
  else args.push("-o", output);
103
124
  if (cssLayers) args.push("--css-layers");
125
+ if (mangleClassNames !== void 0) args.push(`--mangle-class-names=${mangleClassNames}`);
126
+ if (mangleMap) args.push("--mangle-map", mangleMap);
127
+ if (mangleExclude?.length) args.push("--mangle-exclude", mangleExclude.join(","));
104
128
  if (configPath) args.push("--config", configPath);
105
129
  return args;
106
130
  }
107
131
  module.exports = {
108
132
  resolveBinary,
109
133
  resolveConfig,
134
+ configEnablesMangling,
110
135
  withTempConfig,
111
136
  buildArgs
112
137
  };
@@ -158,7 +183,8 @@ const plugin = (opts = {}) => {
158
183
  const args = runner.buildArgs({
159
184
  mode: "stdout",
160
185
  cssLayers: outputToCssLayers,
161
- configPath: cfgPath
186
+ configPath: cfgPath,
187
+ mangleClassNames: runner.configEnablesMangling({ configPath: cfgPath }) ? false : void 0
162
188
  });
163
189
  try {
164
190
  const spawnResult = childProcess.spawnSync(binaryPath, args, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gustcss/postcss",
3
- "version": "0.9.2",
3
+ "version": "0.10.0",
4
4
  "description": "PostCSS plugin for GustCSS",
5
5
  "main": "dist/index.cjs",
6
6
  "types": "dist/index.d.cts",
@@ -31,7 +31,7 @@
31
31
  "access": "public"
32
32
  },
33
33
  "dependencies": {
34
- "gustcss": "^0.9.2"
34
+ "gustcss": "^0.10.0"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "postcss": "^8.0.0"