Files
OpenDTU/webapp/vite.config.ts

100 lines
2.4 KiB
TypeScript
Raw Normal View History

2022-10-17 19:18:45 +02:00
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import viteCompression from 'vite-plugin-compression';
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'
2022-10-17 19:18:45 +02:00
2023-11-16 18:13:46 +01:00
import path from 'path'
// example 'vite.user.ts': export const proxy_target = '192.168.16.107'
let proxy_target;
try {
2024-04-12 20:34:30 +02:00
// eslint-disable-next-line
proxy_target = require('./vite.user.ts').proxy_target;
2024-10-05 23:33:23 +02:00
} catch {
2023-08-09 18:23:50 +02:00
proxy_target = '192.168.20.110';
}
2022-10-17 19:18:45 +02:00
// https://vitejs.dev/config/
2025-09-04 17:55:17 +02:00
export default defineConfig({
2022-10-17 19:18:45 +02:00
plugins: [
vue(),
viteCompression({ deleteOriginFile: true, threshold: 0 }),
cssInjectedByJsPlugin(),
VueI18nPlugin({
/* options */
2023-03-14 18:29:21 +01:00
include: path.resolve(path.dirname(fileURLToPath(import.meta.url)), './src/locales/**.json'),
runtimeOnly: false,
fullInstall: false,
forceStringify: true,
2023-03-23 23:37:58 +01:00
strictMessage: false,
}),
],
2022-10-17 19:18:45 +02:00
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
'~bootstrap': path.resolve(__dirname, 'node_modules/bootstrap'),
2022-10-17 19:18:45 +02:00
}
},
build: {
// Prevent vendor.css being created
cssCodeSplit: false,
outDir: '../webapp_dist',
emptyOutDir: true,
minify: 'terser',
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
},
format: {
comments: false,
},
},
chunkSizeWarningLimit: 1024,
2022-10-17 19:18:45 +02:00
rollupOptions: {
output: {
// Only create one js file
inlineDynamicImports: true,
// Get rid of hash on js file
entryFileNames: 'js/app.js',
// Get rid of hash on css file
assetFileNames: "assets/[name].[ext]",
},
},
target: 'es2022',
2022-10-17 19:18:45 +02:00
},
css: {
preprocessorOptions: {
scss: {
2025-08-26 20:39:18 +02:00
// Required to make bootstrap compile without errors
silenceDeprecations: [
'import',
'color-functions',
'global-builtin',
],
},
},
},
2022-10-17 19:18:45 +02:00
server: {
proxy: {
'^/api': {
target: 'http://' + proxy_target
2022-10-17 19:18:45 +02:00
},
'^/livedata': {
target: 'ws://' + proxy_target,
2022-10-17 19:18:45 +02:00
ws: true,
changeOrigin: true
2022-12-19 21:03:09 +01:00
},
'^/console': {
target: 'ws://' + proxy_target,
2022-12-19 21:03:09 +01:00
ws: true,
changeOrigin: true
2022-10-17 19:18:45 +02:00
}
}
}
2025-09-04 17:55:17 +02:00
})