-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
80 lines (71 loc) · 1.73 KB
/
Copy pathvite.config.ts
File metadata and controls
80 lines (71 loc) · 1.73 KB
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
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import banner from 'vite-plugin-banner'
import { viteStaticCopy as copy, Target } from 'vite-plugin-static-copy'
import { fileURLToPath } from 'node:url'
import { builtinModules } from 'node:module'
const external: string[] = [
'obsidian',
'electron',
'@codemirror/autocomplete',
'@codemirror/collab',
'@codemirror/commands',
'@codemirror/language',
'@codemirror/lint',
'@codemirror/search',
'@codemirror/state',
'@codemirror/view',
'@lezer/common',
'@lezer/highlight',
'@lezer/lr',
...builtinModules
]
const content: string = `/*!
THIS IS A GENERATED/BUNDLED FILE BY VITE
Please visit the github repository of this plugin for the source file:
https://github.com/idlist/flakepiles
*/`
const files = ['main.js', 'styles.css', 'manifest.json']
const copyTargets = () => {
const targets: Target[] = []
for (const file of files) {
targets.push({ src: file, dest: 'dist' })
}
return targets
}
export default defineConfig(({ mode }) => {
const prod = mode == 'production'
const define = {}
if (prod) {
define['process.env.NODE_ENV'] = '"production"'
}
return {
plugins: [
vue(),
banner(content),
copy({ targets: prod ? copyTargets() : [] })
],
define,
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
build: {
target: 'es2018',
outDir: '.',
emptyOutDir: false,
sourcemap: prod ? false : 'inline',
rollupOptions: {
external,
},
lib: {
entry: 'src/main.ts',
fileName: () => 'main.js',
formats: ['cjs'],
cssFileName: 'styles'
},
minify: prod,
},
}
})