123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- import { defineConfig, loadEnv } from "vite";
- import vue from "@vitejs/plugin-vue";
- import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
- import vueJsx from "@vitejs/plugin-vue-jsx";
- import { resolve } from "path";
- function pathResolve(dir) {
- return resolve(process.cwd(), ".", dir);
- }
- export default defineConfig(({ command, mode }) => {
- return {
- resolve: {
- alias: [{
- find: "@",
- replacement: pathResolve("src"),
- },],
- dedupe: ["vue"],
- },
- plugins: [
- vue(),
- vueJsx(),
- createSvgIconsPlugin({
- // 指定需要缓存的图标文件夹
- iconDirs: [resolve(process.cwd(), "src/assets/svg")],
- // 指定symbolId格式
- symbolId: "icon-[dir]-[name]",
- })
- ],
-
- css: {
- // css预处理器
- preprocessorOptions: {
- less: {
- charset: false, // 解决中文乱码
- modifyVars: {
- "arcoblue-6": process.env.VITE_DEV_TYPE == 0 ? "#d1402f" : "#0f2d5c",
- },
- javascriptEnabled: true,
- additionalData: '@import "@/assets/css/theme.less";@import "@/assets/css/global.less";',
- },
- },
- },
- build: {
- minify: true, // 生产环境不生成sourcemap
- target: "es2015",
- // 警报门槛,限制大文件大小
- chunkSizeWarningLimit: 5000,
- rollupOptions: {
- external: [], // 外部化处理那些你不想打包进库的依赖
- // 静态资源分类打包
- output: {
- chunkFileNames: "static/js/[name]-[hash].js",
- entryFileNames: "static/js/[name]-[hash].js",
- assetFileNames: "static/[ext]/[name]-[hash].[ext]",
- },
- },
- },
- server: {
- port: 8088,
- host: "0.0.0.0",
- open: true,
- cors: true,
- hmr: true,
- proxy: {
- "/api": {
- // target:"https://sim.nanodreamtech.com",
- target: "http://192.168.0.78:3001",
- // target: process.env.VITE_DEV_TYPE == 0 ? "http://sim.ainets.net" : "https://flexi.flexistream.link",
- changeOrigin: true,
- ws: true,
- secure: true,
- },
- },
- },
- }
- });
|