-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
/
Copy pathvite.config.js
44 lines (41 loc) · 1.14 KB
/
vite.config.js
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
const fs = require('node:fs')
const path = require('node:path')
const legacy = require('@vitejs/plugin-legacy').default
module.exports = {
base: './',
plugins: [
legacy({
targets: 'IE 11',
modernPolyfills: true
})
],
build: {
cssCodeSplit: false,
manifest: true,
rollupOptions: {
input: {
index: path.resolve(__dirname, 'index.html'),
nested: path.resolve(__dirname, 'nested/index.html')
},
output: {
chunkFileNames(chunkInfo) {
if (chunkInfo.name === 'immutable-chunk') {
return `assets/${chunkInfo.name}.js`
}
return `assets/chunk-[name].[hash].js`
}
}
}
},
// special test only hook
// for tests, remove `<script type="module">` tags and remove `nomodule`
// attrs so that we run the legacy bundle instead.
__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)
}
}