-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathvite.config.base.ts
More file actions
72 lines (67 loc) · 2.07 KB
/
vite.config.base.ts
File metadata and controls
72 lines (67 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
import { readFileSync } from 'fs';
import { resolve } from 'path';
import { defineConfig } from 'vite';
const nodeBuiltinExternals: RegExp[] = [
/^node:/,
/^(path|fs|os|child_process|crypto|http|https|http2|url|querystring|stream|util|events|buffer|assert|net|tty|readline|zlib|constants|tls|domain|dns)$/,
/^fs\/promises$/,
/^dns\/promises$/,
];
const packageJson = JSON.parse( readFileSync( resolve( __dirname, 'package.json' ), 'utf-8' ) );
const packageJsonDependencies = Object.keys( packageJson.dependencies || {} );
export const baseConfig = defineConfig( {
build: {
lib: {
entry: {
main: resolve( __dirname, 'index.ts' ),
'process-manager-daemon': resolve( __dirname, 'process-manager-daemon.ts' ),
'proxy-daemon': resolve( __dirname, 'proxy-daemon.ts' ),
'wordpress-server-child': resolve( __dirname, 'wordpress-server-child.ts' ),
},
name: 'StudioCLI',
formats: [ 'cjs' ],
},
outDir: 'dist/cli',
target: 'node22',
rollupOptions: {
output: {
format: 'cjs',
interop: 'auto',
entryFileNames: '[name].js',
},
external: ( id ) => {
// Bundle the `@wp-playground/blueprints/blueprint-schema-validator` module since we've defined
// that module ourselves
if ( id.includes( 'blueprint-schema-validator' ) ) {
return false;
}
if ( nodeBuiltinExternals.some( ( pattern ) => pattern.test( id ) ) ) {
return true;
}
return packageJsonDependencies.some( ( dep ) => id === dep || id.startsWith( dep + '/' ) );
},
},
commonjsOptions: {
ignoreDynamicRequires: true,
},
sourcemap: true,
minify: false,
},
resolve: {
alias: {
cli: resolve( __dirname, '.' ),
'@studio/common': resolve( __dirname, '../../tools/common' ),
'@wp-playground/blueprints/blueprint-schema-validator': resolve(
__dirname,
'../../node_modules/@wp-playground/blueprints/blueprint-schema-validator.js'
),
},
conditions: [ 'node' ],
mainFields: [ 'main' ],
},
define: {
__ENABLE_STUDIO_AI__: true,
__ENABLE_AGENT_SUITE__: true,
__STUDIO_CLI_VERSION__: JSON.stringify( packageJson.version ),
},
} );