Use cross-platform Node script for CSS minification
Replace shell-only beforeBuildCommand with a Node.js equivalent
that works on macOS, Linux, and Windows without platform-specific
Tauri configs.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2 files changed,
+20 insertions,
-3 deletions
|
1 |
+ |
const { execSync } = require("child_process");
|
|
2 |
+ |
const fs = require("fs");
|
|
3 |
+ |
const path = require("path");
|
|
4 |
+ |
|
|
5 |
+ |
const cssDir = path.join(__dirname, "css");
|
|
6 |
+ |
const src = path.join(cssDir, "styles.css");
|
|
7 |
+ |
const dest = path.join(cssDir, "styles.min.css");
|
|
8 |
+ |
|
|
9 |
+ |
if (!fs.existsSync(dest) || fs.statSync(src).mtimeMs > fs.statSync(dest).mtimeMs) {
|
|
10 |
+ |
console.log("Minifying CSS...");
|
|
11 |
+ |
execSync(`npx --yes clean-css-cli "${src}" -o "${dest}"`, { stdio: "inherit" });
|
|
12 |
+ |
const srcSize = fs.statSync(src).size;
|
|
13 |
+ |
const destSize = fs.statSync(dest).size;
|
|
14 |
+ |
console.log(`CSS minified: ${srcSize} -> ${destSize} bytes`);
|
|
15 |
+ |
} else {
|
|
16 |
+ |
console.log("CSS already up to date");
|
|
17 |
+ |
}
|
| 4 |
4 |
|
"version": "0.3.1",
|
| 5 |
5 |
|
"identifier": "com.goingson.app",
|
| 6 |
6 |
|
"build": {
|
| 7 |
|
- |
"beforeBuildCommand": "./src-tauri/frontend/build-css.sh",
|
| 8 |
|
- |
"beforeDevCommand": "./src-tauri/frontend/build-css.sh",
|
|
7 |
+ |
"beforeBuildCommand": "node src-tauri/frontend/build-css.js",
|
|
8 |
+ |
"beforeDevCommand": "node src-tauri/frontend/build-css.js",
|
| 9 |
9 |
|
"frontendDist": "../src-tauri/frontend"
|
| 10 |
10 |
|
},
|
| 11 |
11 |
|
"app": {
|
| 23 |
23 |
|
}
|
| 24 |
24 |
|
],
|
| 25 |
25 |
|
"security": {
|
| 26 |
|
- |
"csp": null
|
|
26 |
+ |
"csp": "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:"
|
| 27 |
27 |
|
}
|
| 28 |
28 |
|
},
|
| 29 |
29 |
|
"bundle": {
|