generated from homebridge/homebridge-plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrslib.config.ts
114 lines (111 loc) · 2.32 KB
/
rslib.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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import { pluginReact } from '@rsbuild/plugin-react';
import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
import { type LibConfig, defineConfig } from '@rslib/core';
import pkg from './package.json';
const NODE_ENV = process.env.NODE_ENV === 'production' ? 'production' : 'development';
const commonLibConfig: LibConfig = {
syntax: 'es2021',
source: {
entry: {
index: './src/index.ts',
shared: './src/shared/index.ts',
},
},
};
export default defineConfig({
mode: NODE_ENV,
lib: [
// ESM Plugin Configuration
{
...commonLibConfig,
id: 'plugin-esm',
format: 'esm',
shims: {
esm: {
__dirname: true,
},
},
},
// CJS Plugin Configuration
{
...commonLibConfig,
id: 'plugin-cjs',
format: 'cjs',
},
// UI Renderer Configuration
{
id: 'ui-renderer',
format: 'umd',
autoExtension: false,
plugins: [pluginReact()],
source: {
entry: {
index: './src-ui/index.tsx',
},
},
output: {
target: 'web',
filename: {
js: '[name].[contenthash:8].js',
},
assetPrefix: '.',
legalComments: 'none',
distPath: {
root: 'homebridge-ui/public',
},
},
html: {
template: './src-ui/index.html',
inject: 'body',
title: '',
meta: {
charset: false,
viewport: false,
},
},
tools: {
htmlPlugin: true,
},
},
// UI Server Configuration
{
id: 'ui-server',
format: 'esm',
source: {
entry: {
server: './src-ui/server.ts',
},
},
output: {
distPath: {
root: 'homebridge-ui',
},
},
},
],
output: {
minify: NODE_ENV === 'production',
externals: {
'@shared': `${pkg.name}/shared`,
homebridge: 'homebridge',
},
},
source: {
define: {
'process.env.NODE_ENV': JSON.stringify(NODE_ENV),
},
},
tools: {
bundlerChain: (chain) => {
if (process.env.ANALYSIS === 'true') {
chain.plugin('Rsdoctor').use(RsdoctorRspackPlugin, [
{
supports: {
generateTileGraph: true,
},
},
]);
}
},
},
});