-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
57 lines (54 loc) · 1.45 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
57
import fs from 'node:fs'
import path from 'node:path'
import { type Plugin, defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
export default defineConfig({
base: './',
plugins: [
vue({
script: {
fs: {
fileExists: fs.existsSync,
readFile: (file) => fs.readFileSync(file, 'utf-8'),
},
},
}),
copyVuePlugin(),
],
define: {
__VUE_PROD_DEVTOOLS__: JSON.stringify(true),
},
build: {
outDir: 'docs',
},
optimizeDeps: {
exclude: ['@vue/repl'],
},
})
function copyVuePlugin(): Plugin {
return {
name: 'copy-vue',
generateBundle() {
const copyFile = (file: string) => {
const filePath = path.resolve(__dirname, file)
const basename = path.basename(file)
if (!fs.existsSync(filePath)) {
throw new Error(
`${basename} not built. ` +
`Run "nr build vue -f esm-browser" first.`
)
}
this.emitFile({
type: 'asset',
fileName: basename,
source: fs.readFileSync(filePath, 'utf-8'),
})
}
// copyFile(`./node_modules/vue/dist/vue.esm-browser.js`)
// copyFile(`./node_modules/vue/dist/vue.esm-browser.prod.js`)
// copyFile(`./node_modules/vue/dist/vue.runtime.esm-browser.js`)
copyFile(`./node_modules/vue/dist/vue.runtime.esm-browser.prod.js`)
// copyFile(`../server-renderer/dist/server-renderer.esm-browser.js`)
},
}
}