|
|
@ -1,19 +1,13 @@
|
|
|
|
import path from 'path'
|
|
|
|
import path from 'path'
|
|
|
|
|
|
|
|
import type { PluginOption } from 'vite'
|
|
|
|
import { defineConfig, loadEnv } from 'vite'
|
|
|
|
import { defineConfig, loadEnv } from 'vite'
|
|
|
|
import vue from '@vitejs/plugin-vue'
|
|
|
|
import vue from '@vitejs/plugin-vue'
|
|
|
|
import { VitePWA } from 'vite-plugin-pwa'
|
|
|
|
import { VitePWA } from 'vite-plugin-pwa'
|
|
|
|
|
|
|
|
|
|
|
|
export default defineConfig((env) => {
|
|
|
|
function setupPlugins(env: ImportMetaEnv): PluginOption[] {
|
|
|
|
const viteEnv = loadEnv(env.mode, process.cwd()) as unknown as ImportMetaEnv
|
|
|
|
const plugins = [vue()]
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
if (env.VITE_GLOB_APP_PWA === 'true') {
|
|
|
|
resolve: {
|
|
|
|
|
|
|
|
alias: {
|
|
|
|
|
|
|
|
'@': path.resolve(process.cwd(), 'src'),
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
plugins: [
|
|
|
|
|
|
|
|
vue(),
|
|
|
|
|
|
|
|
VitePWA({
|
|
|
|
VitePWA({
|
|
|
|
injectRegister: 'auto',
|
|
|
|
injectRegister: 'auto',
|
|
|
|
manifest: {
|
|
|
|
manifest: {
|
|
|
@ -24,8 +18,21 @@ export default defineConfig((env) => {
|
|
|
|
{ src: 'pwa-512x512.png', sizes: '512x512', type: 'image/png' },
|
|
|
|
{ src: 'pwa-512x512.png', sizes: '512x512', type: 'image/png' },
|
|
|
|
],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
})
|
|
|
|
],
|
|
|
|
}
|
|
|
|
|
|
|
|
return plugins
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default defineConfig((env) => {
|
|
|
|
|
|
|
|
const viteEnv = loadEnv(env.mode, process.cwd()) as unknown as ImportMetaEnv
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
resolve: {
|
|
|
|
|
|
|
|
alias: {
|
|
|
|
|
|
|
|
'@': path.resolve(process.cwd(), 'src'),
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
plugins: setupPlugins(viteEnv),
|
|
|
|
server: {
|
|
|
|
server: {
|
|
|
|
host: '0.0.0.0',
|
|
|
|
host: '0.0.0.0',
|
|
|
|
port: 1002,
|
|
|
|
port: 1002,
|
|
|
|