-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweb-test-runner.config.mjs
More file actions
89 lines (81 loc) · 2.07 KB
/
Copy pathweb-test-runner.config.mjs
File metadata and controls
89 lines (81 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { fromRollup } from "@web/dev-server-rollup";
import rollupCommonjs from "@rollup/plugin-commonjs";
import rollupNodeResolve from "@rollup/plugin-node-resolve";
import rollupReplace from "@rollup/plugin-replace";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const pluginCommonjs = fromRollup(rollupCommonjs, {
plugins: [
rollupNodeResolve({
browser: true,
preferBuiltins: false,
}),
],
});
const replace = fromRollup(rollupReplace);
async function generateDarkCss() {
const { default: postcss } = await import("postcss");
const { postcssFomanticDarkPlugin } = await import("./index.mjs");
const semanticPath = path.resolve(
__dirname,
"node_modules/fomantic-ui/dist/semantic.css",
);
const semantic = fs.readFileSync(semanticPath, "utf-8");
const result = await postcss([postcssFomanticDarkPlugin()]).process(
semantic,
{
from: undefined,
},
);
return result.css;
}
let cachedDarkCss = null;
export default {
rootDir: ".",
files: ["tests/**/*.test.{js,mjs,html}"],
testFramework: {
config: {
timeout: "10000",
},
},
concurrency: 1,
preserveSymlinks: true,
nodeResolve: {
browser: true,
preferBuiltins: false,
},
mimeTypes: {
"**/*.cjs": "js",
},
plugins: [
replace({
include: ["node_modules/postcss/**/*.js"],
preventAssignment: true,
"process.env.NODE_ENV": '"test"',
}),
pluginCommonjs({
include: ["node_modules/**"],
esmExternals: true,
defaultIsModuleExports: true,
requireReturnsDefault: true,
strictRequires: false,
}),
{
name: "dark-theme-css",
async serve(context) {
if (context.path === "/generated/dark-theme.css") {
if (!cachedDarkCss) {
cachedDarkCss = await generateDarkCss();
}
return {
body: cachedDarkCss,
type: "css",
contentType: "text/css",
};
}
},
},
],
};