forked from marktext/muya
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
56 lines (55 loc) · 1.53 KB
/
vite.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
import libAssetsPlugin from '@laynezh/vite-plugin-lib-assets';
import { fileURLToPath, URL } from 'node:url';
import { resolve } from 'path';
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';
export default defineConfig({
resolve: {
alias: [
{
find: '@muya',
replacement: fileURLToPath(new URL('./packages', import.meta.url)),
},
],
},
esbuild: {
supported: {
'top-level-await': true, //browsers can handle top-level-await features
},
},
plugins: [
dts({ entryRoot: 'packages' }),
libAssetsPlugin({
outputPath: (url) => {
return url.endsWith('.png') ? 'assets/icons' : 'assets/fonts';
},
}),
],
build: {
copyPublicDir: false,
sourcemap: false,
lib: {
entry: {
index: resolve(__dirname, 'packages/index.ts'),
'locales/en': resolve(__dirname, 'packages/locales/en.ts'),
'locales/ja': resolve(__dirname, 'packages/locales/ja.ts'),
'locales/zh': resolve(__dirname, 'packages/locales/zh.ts'),
'state/markdownToHtml': resolve(
__dirname,
'packages/state/markdownToHtml.ts'
),
'ui/index': resolve(__dirname, 'packages/ui/index.ts'),
},
formats: ['es'],
},
rollupOptions: {
output: {
entryFileNames: '[name].js',
// Put chunk files at <output>/chunks
chunkFileNames: 'chunks/[name].[hash].js',
// Put chunk styles at <output>/styles
assetFileNames: 'assets/[name][extname]',
},
},
},
});