-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.mts
More file actions
49 lines (45 loc) · 1.45 KB
/
build.mts
File metadata and controls
49 lines (45 loc) · 1.45 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
import { resolve } from 'node:path';
import { makeEntryPointPlugin } from '@extension/hmr';
import { getContentScriptEntries, withPageConfig } from '@extension/vite-config';
import { IS_DEV } from '@extension/env';
import { build } from 'vite';
import { build as buildTW } from 'tailwindcss/lib/cli/build';
const rootDir = resolve(import.meta.dirname);
const srcDir = resolve(rootDir, 'src');
const matchesDir = resolve(srcDir, 'matches');
const configs = Object.entries(getContentScriptEntries(matchesDir)).map(([name, entry]) => ({
name,
config: withPageConfig({
mode: IS_DEV ? 'development' : undefined,
resolve: {
alias: {
'@src': srcDir,
},
},
publicDir: resolve(rootDir, 'public'),
plugins: [IS_DEV && makeEntryPointPlugin()],
build: {
lib: {
name: name,
formats: ['iife'],
entry,
fileName: name,
},
outDir: resolve(rootDir, '..', '..', 'dist', 'content-ui'),
},
}),
}));
const builds = configs.map(async ({ name, config }) => {
const folder = resolve(matchesDir, name);
const args = {
['--input']: resolve(folder, 'index.css'),
['--output']: resolve(rootDir, 'dist', name, 'index.css'),
['--config']: resolve(rootDir, 'tailwind.config.ts'),
['--watch']: IS_DEV,
};
await buildTW(args);
//@ts-expect-error This is hidden property into vite's resolveConfig()
config.configFile = false;
await build(config);
});
await Promise.all(builds);