2022-04-17 22:43:58 +00:00
|
|
|
import { defineConfig, HmrOptions } from 'vite'
|
2022-04-16 11:34:39 +00:00
|
|
|
import { createVuePlugin as Vue2 } from 'vite-plugin-vue2'
|
|
|
|
import ScriptSetup from 'unplugin-vue2-script-setup/vite'
|
2022-02-21 14:07:07 +00:00
|
|
|
|
2022-04-17 22:43:58 +00:00
|
|
|
// @ts-ignore
|
2022-02-21 22:16:48 +00:00
|
|
|
import path from 'path'
|
2022-02-21 14:07:07 +00:00
|
|
|
|
2022-04-17 22:43:58 +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')
|
2022-04-17 22:43:58 +00:00
|
|
|
} 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/
|
2022-04-17 22:43:58 +00:00
|
|
|
export default defineConfig(() => ({
|
|
|
|
envPrefix: 'VUE_',
|
2022-02-21 22:16:48 +00:00
|
|
|
plugins: [
|
2022-04-16 11:34:39 +00:00
|
|
|
// https://github.com/underfin/vite-plugin-vue2
|
|
|
|
Vue2(),
|
|
|
|
|
|
|
|
// https://github.com/antfu/unplugin-vue2-script-setup
|
|
|
|
ScriptSetup(),
|
|
|
|
|
2022-02-22 11:34:54 +00: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 14:07:07 +00:00
|
|
|
resolve: {
|
|
|
|
alias: {
|
2022-04-23 07:37:43 +00:00
|
|
|
'~': path.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: {
|
|
|
|
main: path.resolve(__dirname, './index.html'),
|
|
|
|
embed: path.resolve(__dirname, './embed.html')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-04-17 22:43:58 +00:00
|
|
|
}))
|