-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathtsup.config.ts
73 lines (69 loc) · 1.71 KB
/
tsup.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
import { defineConfig } from 'tsup';
import { writeFileSync, readFileSync } from 'fs';
import { join, resolve } from 'path';
export default defineConfig({
entry: ['src/pages/web/SearchChat.tsx'],
format: ['esm', 'cjs'],
dts: true,
splitting: false,
sourcemap: true,
clean: true,
external: [
'react',
'react-dom',
],
treeshake: true,
minify: true,
esbuildOptions(options) {
options.bundle = true;
options.platform = 'browser';
options.loader = {
'.css': 'css',
'.scss': 'css',
'.svg': 'dataurl',
'.png': 'dataurl',
'.jpg': 'dataurl',
},
options.alias = {
'@': resolve(__dirname, './src')
}
},
esbuildPlugins: [
{
name: 'jsx-import-source',
setup(build) {
build.initialOptions.jsx = 'automatic';
build.initialOptions.jsxImportSource = 'react';
},
},
],
outDir: 'dist/search-chat',
async onSuccess() {
const projectPackageJson = JSON.parse(
readFileSync(join(__dirname, 'package.json'), 'utf-8')
);
const packageJson = {
name: "search-chat",
version: "1.0.0",
main: "SearchChat.cjs",
module: "SearchChat.js",
types: "SearchChat.d.ts",
dependencies: projectPackageJson.dependencies,
peerDependencies: {
"react": "^18.0.0",
"react-dom": "^18.0.0"
}
};
const tauriDeps = Object.keys(packageJson.dependencies).filter(dep =>
dep.includes('@tauri-apps') ||
dep.includes('tauri-plugin')
);
tauriDeps.forEach(dep => {
delete packageJson.dependencies[dep];
});
writeFileSync(
join(__dirname, 'dist/search-chat/package.json'),
JSON.stringify(packageJson, null, 2)
);
}
});