Skip to content

Commit 1e6e91f

Browse files
feat(web): replace Tailwind CDN with build process
- modified package-lock.json
1 parent a0e6b8f commit 1e6e91f

File tree

8 files changed

+1377
-95
lines changed

8 files changed

+1377
-95
lines changed

package-lock.json

Lines changed: 1342 additions & 86 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
},
1111
"scripts": {
1212
"build": "vite build",
13-
"postbuild": "node scripts/build-docs.js",
13+
"build:web": "node node_modules/@tailwindcss/cli/dist/index.mjs -i ./web/input.css -o ./web/output.css --minify",
14+
"watch:web": "node node_modules/@tailwindcss/cli/dist/index.mjs -i ./web/input.css -o ./web/output.css --watch",
15+
"postbuild": "npm run build:web && node scripts/build-docs.js",
1416
"dev": "node --watch index.js",
1517
"start": "node index.js",
1618
"local": "node index.js",
@@ -51,8 +53,12 @@
5153
"@commitlint/cli": "^20.1.0",
5254
"@commitlint/config-conventional": "^20.0.0",
5355
"@programinglive/commiter": "^1.1.8",
56+
"@tailwindcss/cli": "^4.1.17",
57+
"autoprefixer": "^10.4.22",
5458
"husky": "^9.1.7",
55-
"standard-version": "^9.5.0"
59+
"postcss": "^8.5.6",
60+
"standard-version": "^9.5.0",
61+
"tailwindcss": "^4.1.17"
5662
},
5763
"standard-version": {
5864
"releaseCommitMessageFormat": "chore(release): {{currentTag}} 🚀",
@@ -103,4 +109,4 @@
103109
}
104110
]
105111
}
106-
}
112+
}

tailwind.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/** @type {import('tailwindcss').Config} */
2+
export default {
3+
content: [
4+
"./web/**/*.{html,js}",
5+
],
6+
theme: {
7+
extend: {},
8+
},
9+
plugins: [],
10+
}

tests/build.test.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@ test('build generates dist/index.mjs file', async () => {
1111
const { stderr } = await exec('npm run build');
1212
// Allow the known vite warning about node:process
1313
const knownWarning = '[plugin vite:resolve] Module "node:process" has been externalized for browser compatibility';
14+
const tailwindOutput = '≈ tailwindcss';
1415
const actualStderr = stderr.replace(/\x1B\[[0-9;]*m/g, ''); // Remove ANSI codes
1516
assert(
16-
actualStderr === '' || actualStderr.includes(knownWarning),
17+
actualStderr === '' || actualStderr.includes(knownWarning) || actualStderr.includes(tailwindOutput),
1718
`Build should not have unexpected errors: ${actualStderr}`
1819
);
19-
20+
2021
// Verify the file exists
2122
const distPath = path.join(process.cwd(), 'dist', 'index.mjs');
2223
await access(distPath);
23-
24+
2425
// Verify it contains expected content
2526
const content = await readFile(distPath, 'utf-8');
2627
assert(content.includes('main'), 'Bundle should contain main function');
@@ -40,7 +41,7 @@ test('build script exists in package.json', async () => {
4041
const packagePath = path.join(process.cwd(), 'package.json');
4142
const content = await readFile(packagePath, 'utf-8');
4243
const pkg = JSON.parse(content);
43-
44+
4445
assert.strictEqual(typeof pkg.scripts.build, 'string');
4546
assert(pkg.scripts.build.includes('vite build'));
4647
});

web/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta charset="UTF-8">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<title>Dev Workflow Dashboard</title>
8-
<script src="https://cdn.tailwindcss.com"></script>
8+
<link rel="stylesheet" href="/output.css">
99
<script src="https://unpkg.com/lucide@latest"></script>
1010
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
1111
</head>

web/input.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;

web/output.css

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/server.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ async function start() {
8282
const url = new URL(req.url, `http://${req.headers.host}`);
8383
const userId = url.searchParams.get("user") || "default";
8484

85-
if (req.method === "GET" && url.pathname === "/") {
85+
if (req.method === "GET" && url.pathname === "/output.css") {
86+
const css = await readFile(join(__dirname, "output.css"), "utf-8");
87+
res.writeHead(200, { "Content-Type": "text/css" });
88+
res.end(css);
89+
} else if (req.method === "GET" && url.pathname === "/") {
8690
const html = await readFile(join(__dirname, "index.html"), "utf-8");
8791
res.writeHead(200, { "Content-Type": "text/html" });
8892
res.end(html);

0 commit comments

Comments
 (0)