1
|
|
|
import createVuePlugin from '@vitejs/plugin-vue2'; |
2
|
|
|
import {defineConfig} from 'vite'; |
3
|
|
|
import checker from 'vite-plugin-checker'; |
4
|
|
|
import tailwindcss from "@tailwindcss/vite"; |
5
|
|
|
import {visualizer} from 'rollup-plugin-visualizer'; |
6
|
|
|
import viteCompressionPlugin from 'vite-plugin-compression'; |
7
|
|
|
import {viteExternalsPlugin} from 'vite-plugin-externals'; |
8
|
|
|
import viteRestartPlugin from 'vite-plugin-restart'; |
9
|
|
|
import * as path from 'path'; |
10
|
|
|
|
11
|
|
|
// https://vitejs.dev/config/ |
12
|
|
|
export default defineConfig(({command}) => ({ |
13
|
|
|
base: command === 'serve' ? '' : '/dist/', |
14
|
|
|
build: { |
15
|
|
|
emptyOutDir: true, |
16
|
|
|
manifest: 'manifest.json', |
17
|
|
|
outDir: '../src/web/assets/dist', |
18
|
|
|
rollupOptions: { |
19
|
|
|
input: { |
20
|
|
|
'imageoptimize': 'src/js/ImageOptimize.js', |
21
|
|
|
'field': 'src/js/OptimizedImagesField.js', |
22
|
|
|
'welcome': 'src/js/Welcome.js', |
23
|
|
|
}, |
24
|
|
|
}, |
25
|
|
|
sourcemap: true |
26
|
|
|
}, |
27
|
|
|
plugins: [ |
28
|
|
|
viteRestartPlugin({ |
29
|
|
|
reload: [ |
30
|
|
|
'../src/templates/**/*', |
31
|
|
|
], |
32
|
|
|
}), |
33
|
|
|
createVuePlugin(), |
34
|
|
|
viteExternalsPlugin({ |
35
|
|
|
'vue': 'Vue', |
36
|
|
|
}), |
37
|
|
|
viteCompressionPlugin({ |
38
|
|
|
filter: /\.(js|mjs|json|css|map)$/i |
39
|
|
|
}), |
40
|
|
|
visualizer({ |
41
|
|
|
filename: '../src/web/assets/dist/stats.html', |
42
|
|
|
template: 'treemap', |
43
|
|
|
sourcemap: true, |
44
|
|
|
}), |
45
|
|
|
tailwindcss(), |
46
|
|
|
checker({ |
47
|
|
|
eslint: { |
48
|
|
|
lintCommand: 'eslint "./src/**/*.{js,ts}"', |
49
|
|
|
useFlatConfig: true, |
50
|
|
|
dev: { |
51
|
|
|
overrideConfig: { |
52
|
|
|
cache: true, |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
}, |
56
|
|
|
stylelint: { |
57
|
|
|
lintCommand: 'stylelint ./src/**/*.{css} --allow-empty-input --fix', |
58
|
|
|
dev: { |
59
|
|
|
overrideConfig: { |
60
|
|
|
allowEmptyInput: true, |
61
|
|
|
cache: true, |
62
|
|
|
fix: false |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
}, |
66
|
|
|
typescript: true, |
67
|
|
|
vueTsc: true, |
68
|
|
|
}), |
69
|
|
|
], |
70
|
|
|
optimizeDeps: { |
71
|
|
|
include: ['vue-confetti'], |
72
|
|
|
}, |
73
|
|
|
resolve: { |
74
|
|
|
alias: [ |
75
|
|
|
{find: '@', replacement: path.resolve(__dirname, './src')}, |
76
|
|
|
{find: 'vue', replacement: 'vue/dist/vue.esm.js'}, |
77
|
|
|
], |
78
|
|
|
preserveSymlinks: true, |
79
|
|
|
}, |
80
|
|
|
server: { |
81
|
|
|
// Allow cross-origin requests -- https://github.com/vitejs/vite/security/advisories/GHSA-vg6x-rcgg-rjx6 |
82
|
|
|
allowedHosts: true, |
83
|
|
|
cors: { |
84
|
|
|
origin: /https?:\/\/([A-Za-z0-9\-\.]+)?(localhost|\.local|\.test|\.site)(?::\d+)?$/ |
85
|
|
|
}, |
86
|
|
|
fs: { |
87
|
|
|
strict: false |
88
|
|
|
}, |
89
|
|
|
headers: { |
90
|
|
|
"Access-Control-Allow-Private-Network": "true", |
91
|
|
|
}, |
92
|
|
|
host: '0.0.0.0', |
93
|
|
|
origin: 'http://localhost:' + process.env.DEV_PORT, |
94
|
|
|
port: parseInt(process.env.DEV_PORT), |
95
|
|
|
strictPort: true, |
96
|
|
|
} |
97
|
|
|
})); |
98
|
|
|
|