forked from vitejs/vite-plugin-vue
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
35 lines (34 loc) · 924 Bytes
/
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
import path from 'node:path'
import fs from 'node:fs'
import { defineConfig } from 'rolldown-vite'
import vuePlugin from '@vitejs/plugin-vue'
import legacyPlugin from '@vitejs/plugin-legacy'
export default defineConfig({
base: '',
resolve: {
alias: {
'@': __dirname,
},
},
plugins: [
legacyPlugin({
targets: ['defaults', 'not IE 11', 'chrome > 48'],
}),
vuePlugin(),
],
build: {
minify: false,
},
// special test only hook
// for tests, remove `<script type="module">` tags and remove `nomodule`
// attrs so that we run the legacy bundle instead.
// @ts-ignore
__test__() {
const indexPath = path.resolve(__dirname, './dist/index.html')
let index = fs.readFileSync(indexPath, 'utf-8')
index = index
.replace(/<script type="module".*?<\/script>/g, '')
.replace(/<script nomodule/g, '<script')
fs.writeFileSync(indexPath, index)
},
})