funquail/front/vite.config.ts

72 lines
1.8 KiB
TypeScript
Raw Normal View History

2022-07-04 22:52:53 +00:00
import type { HmrOptions } from 'vite'
import { defineConfig } from 'vite'
2022-04-18 10:24:47 +02: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 15:07:07 +01: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 15:07:07 +01:00
// https://vitejs.dev/config/
export default defineConfig(() => ({
envPrefix: 'VUE_',
plugins: [
2022-04-16 13:34:39 +02:00
// https://github.com/underfin/vite-plugin-vue2
2022-04-18 10:24:47 +02:00
Vue({
template: {
compilerOptions: {
compatConfig: {
MODE: 2
}
}
}
}),
2022-04-16 13:34:39 +02: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-02-22 12:34:54 +01:00
{
name: 'fix-fomantic-ui-css',
transform (src, id) {
if (id.includes('fomantic-ui-css') && id.endsWith('.min.js')) {
return `import jQuery from 'jquery';${src}`
}
}
2022-03-08 09:37:37 +00:00
}
2022-06-23 17:21:06 +00:00
],
server: { port, hmr },
2022-02-21 15:07:07 +01: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 19:38:14 +02: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
}
}
}
}))