funkwhale/front/vite.config.ts

68 wiersze
1.6 KiB
TypeScript
Czysty Zwykły widok Historia

2022-07-04 22:52:53 +00:00
import type { HmrOptions } from 'vite'
import { defineConfig } from 'vite'
2022-04-18 08:24:47 +00:00
import Vue from '@vitejs/plugin-vue'
2022-04-30 13:25:59 +00:00
import { VitePWA } from 'vite-plugin-pwa'
import { resolve } from 'path'
2022-02-21 14:07:07 +00:00
const port = +(process.env.VUE_PORT ?? 8080)
2022-06-23 17:21:06 +00:00
const hmr = {
port: process.env.HMR_PORT || (process.env.FUNKWHALE_PROTOCOL === 'https' ? 443 : port),
protocol: process.env.HMR_PROTOCOL || (process.env.FUNKWHALE_PROTOCOL === 'https' ? 'wss' : 'ws')
} as HmrOptions
2022-06-23 17:21:06 +00:00
if (process.env.GITPOD_WORKSPACE_URL) {
hmr.host = process.env.GITPOD_WORKSPACE_URL.replace('https://', `${process.env.HMR_PORT ?? process.env.VUE_PORT ?? 4000}-`)
hmr.clientPort = 443
hmr.protocol = 'wss'
delete hmr.port
}
2022-02-21 14:07:07 +00:00
// https://vitejs.dev/config/
export default defineConfig(() => ({
envPrefix: 'VUE_',
plugins: [
2022-04-16 11:34:39 +00:00
// https://github.com/underfin/vite-plugin-vue2
2022-04-18 08:24:47 +00:00
Vue({
template: {
compilerOptions: {
compatConfig: {
MODE: 2
}
}
}
}),
2022-04-16 11:34:39 +00:00
2022-04-30 13:25:59 +00:00
// https://github.com/antfu/vite-plugin-pwa
VitePWA({
strategies: 'injectManifest',
srcDir: 'src',
filename: 'serviceWorker.ts',
devOptions: {
enabled: true,
type: 'module',
2022-07-20 14:43:32 +00:00
navigateFallback: 'index.html',
webManifestUrl: '/front/manifest.json'
2022-04-30 13:25:59 +00:00
}
2022-07-20 18:49:11 +00:00
})
2022-06-23 17:21:06 +00:00
],
2022-07-21 14:13:42 +00:00
server: {
port,
hmr: process.env.DISABLE_HMR ? false : hmr
},
2022-02-21 14:07:07 +00:00
resolve: {
alias: {
2022-04-30 13:25:59 +00:00
'~': resolve(__dirname, './src')
2022-06-23 17:21:06 +00:00
}
2022-04-02 17:38:14 +00:00
},
2022-06-13 09:53:36 +00:00
build: {
rollupOptions: {
input: {
2022-06-26 07:27:16 +00:00
main: resolve(__dirname, './index.html'),
embed: resolve(__dirname, './embed.html')
2022-06-13 09:53:36 +00:00
}
}
}
}))