|
1 | 1 | import fs from "node:fs"; |
2 | 2 | import path from "node:path"; |
3 | | -import { describe, test, beforeAll, afterAll } from "vitest"; |
| 3 | +import { describe, test, beforeAll } from "vitest"; |
4 | 4 | import esbuild from "esbuild"; |
5 | 5 | import cssPlugin from "../src"; |
6 | 6 | import glob from "tiny-glob"; |
@@ -28,7 +28,7 @@ describe("Test plugin with esbuild", async () => { |
28 | 28 | }); |
29 | 29 |
|
30 | 30 | test("Should contain -moz-", ({ expect }) => { |
31 | | - const test = fs.readFileSync(path.resolve(exampleBuildDir, "server", "index.css"), "utf-8"); |
| 31 | + const test = fs.readFileSync(path.resolve(exampleBuildDir, "index.css"), "utf-8"); |
32 | 32 | expect(/-moz-/.test(test)).toBe(true); |
33 | 33 | }); |
34 | 34 | }); |
@@ -66,3 +66,31 @@ describe("Test plugin with esbuild and options", async () => { |
66 | 66 | expect(/-moz-/.test(test)).toBe(false); |
67 | 67 | }); |
68 | 68 | }); |
| 69 | + |
| 70 | +describe("Only server styles", () => { |
| 71 | + const exampleBuildDir = path.resolve(process.cwd(), "test-build1"); |
| 72 | + |
| 73 | + beforeAll(async () => { |
| 74 | + await esbuild.build({ |
| 75 | + format: "cjs", |
| 76 | + target: "es2019", |
| 77 | + sourcemap: false, |
| 78 | + bundle: true, |
| 79 | + minify: true, |
| 80 | + plugins: [cssPlugin()], |
| 81 | + entryPoints: await glob("../example2/src/**/*.*"), |
| 82 | + external: ["react", "react-dom"], |
| 83 | + outdir: "./test-build1", |
| 84 | + }); |
| 85 | + }); |
| 86 | + |
| 87 | + test(`Test CSS Class Hash`, ({ expect }) => { |
| 88 | + const text = fs.readFileSync(path.resolve(exampleBuildDir, "server", "index.js"), "utf-8"); |
| 89 | + expect(/{fork:["'][^"']*fork[^"']*["']/.test(text)).toBe(true); |
| 90 | + }); |
| 91 | + |
| 92 | + test("Should contain -moz-", ({ expect }) => { |
| 93 | + const test = fs.readFileSync(path.resolve(exampleBuildDir, "index.css"), "utf-8"); |
| 94 | + expect(/-moz-/.test(test)).toBe(true); |
| 95 | + }); |
| 96 | +}); |
0 commit comments