-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
60 lines (58 loc) · 1.55 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { defineConfig, loadEnv } from 'vite'
import preprocess from 'svelte-preprocess'
import { svelte } from '@sveltejs/vite-plugin-svelte'
import createServiceWorkerPlugin from './plugins/create-service-worker'
const config = defineConfig(async ({ mode }) => {
const env = loadEnv(mode, process.cwd())
return {
server: {
host: env.VITE_HOST,
port: Number(env.VITE_PORT),
open: env.VITE_OPEN_BROWSER === 'true',
},
build: {
outDir: env.VITE_OUT_DIR,
rollupOptions: {
output: {
assetFileNames: (assetInfo) => {
const info = assetInfo.name.split('.')
let ext = info[info.length - 1]
if (/png|jpe?g|svg|gif|tiff|bmp|ico|webp/i.test(ext))
{
ext = 'images/'
}
else if (/woff|woff2/.test(ext))
{
ext = 'fonts/'
}
else
{
ext = ''
}
return `assets/${ext}[name]-[hash][extname]`
},
},
},
},
define: {},
plugins: [
svelte({
preprocess: preprocess(),
extensions: ['.svelte'],
compilerOptions: {},
onwarn(warning, defaultHandler) {
switch (warning.code)
{
case 'css-unused-selector':
case 'a11y-label-has-associated-control':
case 'unused-export-let':
return
}
defaultHandler(warning)
},
}),
createServiceWorkerPlugin(),
],
}
})
export default config