import { fileURLToPath, URL } from 'node:url' import * as VueRouter from 'vue-router' import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import path from 'path' let time = new Date(new Date().getTime()) let year = time.getFullYear() const month = (time.getMonth() + 1).toString().padStart(2, '0') const date = (time.getDate()).toString().padStart(2, '0') const hours = (time.getHours()).toString().padStart(2, '0') const minute = (time.getMinutes()).toString().padStart(2, '0') const second = (time.getSeconds()).toString().padStart(2, '0') let version = year + month + date + '_' + hours + minute + second; export default defineConfig({ resolve:{ // 别名配置 alias:{ "@": path.resolve(__dirname, './src') } }, base: './', plugins: [vue()], css: { preprocessorOptions: { less: { javascriptEnabled: true, outputStyle: 'expanded' }, }, }, eslint: { enable: false, }, esbuild:{charset:'ascii'}, build: { minify: 'terser', outDir: 'dist', index: 'index.html', rollupOptions: { output: { chunkFileNames: 'static/js/daotianAdmin-' + version + '.js', entryFileNames: 'static/js/daotianAdmin-' + version + '.js', assetFileNames: 'static/[ext]/[name]-[hash].[ext]', // 资源文件像 字体,图片等 }, }, terserOptions: { compress: { drop_console: true, drop_debugger: true, } }, sourcemap: false, }, server: { port: 3001, host: '0.0.0.0', disableHostCheck: true, proxy: { '/api': { target: 'http://test.renminshitang.com.cn/pc', changeOrigin: true, ws: true, pathRewrite: { '^/api': '' }, }, } }, })