-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
40 lines (38 loc) · 1.06 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
import * as path from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { YN_LIBS, getExtensionBasePath } from '@yank-note/runtime-api'
const OUT_DIR = 'dist/'
// https://vitejs.dev/config/
export default defineConfig({
base: path.join(getExtensionBasePath(process.env.npm_package_name), OUT_DIR).replace(/\\/g, '/'),
plugins: [vue()],
define: {
__EXTENSION_VERSION__: JSON.stringify(process.env.npm_package_version),
__EXTENSION_ID__: JSON.stringify(process.env.npm_package_name),
},
resolve: {
alias: [
{ find: /^@\//, replacement: path.resolve(__dirname, 'src') + '/' },
],
},
build: {
minify: 'terser',
lib: {
entry: path.resolve(__dirname, 'src/main.ts'),
formats: ['iife'],
name: process.env.npm_package_name.replace(/[^a-zA-Z0-9_]/g, '_'),
fileName: () => 'index.js',
},
outDir: OUT_DIR,
rollupOptions: {
external: Object.keys(YN_LIBS),
output: {
globals: {
window: 'window',
...YN_LIBS,
}
}
}
},
})