2024-11-30 14:17:59 +00:00
|
|
|
import { readdirSync } from 'node:fs';
|
2024-06-06 13:16:59 +00:00
|
|
|
import path from 'node:path';
|
|
|
|
import process from 'node:process';
|
2023-03-19 23:07:18 +00:00
|
|
|
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite';
|
2021-11-03 16:40:31 +00:00
|
|
|
import vue from '@vitejs/plugin-vue';
|
2024-06-06 13:16:59 +00:00
|
|
|
import type { Plugin } from 'vite';
|
2022-08-09 15:39:45 +00:00
|
|
|
import prismjs from 'vite-plugin-prismjs';
|
2021-11-03 16:40:31 +00:00
|
|
|
import WindiCSS from 'vite-plugin-windicss';
|
|
|
|
import svgLoader from 'vite-svg-loader';
|
2024-12-24 08:52:28 +00:00
|
|
|
import type { ViteUserConfig } from 'vitest/config';
|
2024-04-29 19:33:45 +00:00
|
|
|
import { defineConfig } from 'vitest/config';
|
2021-11-03 16:40:31 +00:00
|
|
|
|
2024-06-06 13:16:59 +00:00
|
|
|
function woodpeckerInfoPlugin(): Plugin {
|
2021-12-21 09:52:10 +00:00
|
|
|
return {
|
|
|
|
name: 'woodpecker-info',
|
|
|
|
configureServer() {
|
|
|
|
const info =
|
2023-07-16 19:31:36 +00:00
|
|
|
'1) Please add `WOODPECKER_DEV_WWW_PROXY=http://localhost:8010` to your `.env` file.\n' +
|
|
|
|
'After starting the woodpecker server as well you should now be able to access the UI at http://localhost:8000/\n\n' +
|
|
|
|
'2) If you want to run the vite dev server (`pnpm start`) within a container please set `VITE_DEV_SERVER_HOST=0.0.0.0`.';
|
2021-12-21 09:52:10 +00:00
|
|
|
console.log(info);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-06-06 13:16:59 +00:00
|
|
|
function externalCSSPlugin(): Plugin {
|
2023-11-09 13:13:11 +00:00
|
|
|
return {
|
|
|
|
name: 'external-css',
|
|
|
|
transformIndexHtml: {
|
2023-11-29 12:40:51 +00:00
|
|
|
order: 'post',
|
|
|
|
handler() {
|
2023-11-09 13:13:11 +00:00
|
|
|
return [
|
|
|
|
{
|
|
|
|
tag: 'link',
|
|
|
|
attrs: { rel: 'stylesheet', type: 'text/css', href: '/assets/custom.css' },
|
|
|
|
injectTo: 'head',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-11-03 16:40:31 +00:00
|
|
|
// https://vitejs.dev/config/
|
|
|
|
export default defineConfig({
|
|
|
|
plugins: [
|
|
|
|
vue(),
|
2023-03-19 23:07:18 +00:00
|
|
|
VueI18nPlugin({
|
2022-05-16 19:18:48 +00:00
|
|
|
include: path.resolve(__dirname, 'src/assets/locales/**'),
|
|
|
|
}),
|
2022-12-29 12:41:59 +00:00
|
|
|
(() => {
|
|
|
|
const virtualModuleId = 'virtual:vue-i18n-supported-locales';
|
|
|
|
const resolvedVirtualModuleId = `\0${virtualModuleId}`;
|
|
|
|
|
|
|
|
const filenames = readdirSync('src/assets/locales/').map((filename) => filename.replace('.json', ''));
|
|
|
|
|
|
|
|
return {
|
|
|
|
name: 'vue-i18n-supported-locales',
|
2024-06-06 13:16:59 +00:00
|
|
|
|
2022-12-29 12:41:59 +00:00
|
|
|
resolveId(id) {
|
|
|
|
if (id === virtualModuleId) {
|
|
|
|
return resolvedVirtualModuleId;
|
|
|
|
}
|
|
|
|
},
|
2024-06-06 13:16:59 +00:00
|
|
|
|
2022-12-29 12:41:59 +00:00
|
|
|
load(id) {
|
|
|
|
if (id === resolvedVirtualModuleId) {
|
|
|
|
return `export const SUPPORTED_LOCALES = ${JSON.stringify(filenames)}`;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
})(),
|
2021-11-03 16:40:31 +00:00
|
|
|
WindiCSS(),
|
|
|
|
svgLoader(),
|
2023-11-09 13:13:11 +00:00
|
|
|
externalCSSPlugin(),
|
2021-12-21 09:52:10 +00:00
|
|
|
woodpeckerInfoPlugin(),
|
2022-08-09 15:39:45 +00:00
|
|
|
prismjs({
|
|
|
|
languages: ['yaml'],
|
|
|
|
}),
|
2021-11-03 16:40:31 +00:00
|
|
|
],
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
'~/': `${path.resolve(__dirname, 'src')}/`,
|
|
|
|
},
|
|
|
|
},
|
2021-12-21 09:52:10 +00:00
|
|
|
logLevel: 'warn',
|
|
|
|
server: {
|
2024-06-06 13:16:59 +00:00
|
|
|
host: process.env.VITE_DEV_SERVER_HOST ?? '127.0.0.1',
|
2021-12-21 09:52:10 +00:00
|
|
|
port: 8010,
|
|
|
|
},
|
2024-04-29 19:33:45 +00:00
|
|
|
test: {
|
|
|
|
globals: true,
|
|
|
|
environment: 'jsdom',
|
|
|
|
},
|
2024-12-24 08:52:28 +00:00
|
|
|
} as ViteUserConfig);
|