generated from homebridge/homebridge-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodern.config.ts
46 lines (44 loc) · 1.25 KB
/
modern.config.ts
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
import { moduleTools, defineConfig } from '@modern-js/module-tools';
import path from 'path';
const baseOutDir = path.resolve(__dirname, './homebridge-ui');
export default defineConfig({
plugins: [moduleTools()],
buildConfig: [
{
buildType: 'bundle',
input: ['ui-src/server.ts'],
outDir: baseOutDir,
tsconfig: 'ui-src/tsconfig.json',
externals: ['@homebridge/plugin-ui-utils', '@api/index'],
dts: false,
hooks: [
{
name: 'renderChunk',
apply(compiler) {
compiler.hooks.renderChunk.tapPromise('renderChunk', async (chunk) => {
if (chunk.type === 'chunk') {
chunk.contents = chunk.contents.replace(/@api\/index/g, '../dist/api');
}
return chunk;
});
},
},
],
},
{
buildType: 'bundle',
input: ['ui-src/index.tsx'],
outDir: path.resolve(baseOutDir, 'public'),
autoExternal: false,
platform: 'browser',
tsconfig: 'ui-src/tsconfig.json',
copy: {
patterns: [{ from: './index.html', context: __dirname }],
},
define: {
'process.env.NODE_ENV': process.env.NODE_ENV ?? 'development',
},
dts: false,
},
],
});