1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- import path from "path";
- import { defineConfig } from "vite";
- import vue from "@vitejs/plugin-vue";
- import Components from "unplugin-vue-components/vite";
- import { VantResolver } from "unplugin-vue-components/resolvers";
- import { postcssConfig } from "./postcss.config.js";
- // const target = 'http://192.168.2.40:10099';
- const target = 'http://192.168.2.5:10010';
- // const target = 'http://1.94.62.58:10014';
- // const target = 'http://192.168.2.17:10010';
- export default defineConfig({
- define: {
- "import.meta.env.postConfig": postcssConfig,
- },
- plugins: [
- vue(),
- Components({
- resolvers: [VantResolver()],
- }),
- ],
- css:{
- preprocessorOptions:{
- scss:{
- api:"modern-compiler",
- silenceDeprecations: ["legacy-js-api"],
- additionalData: `@use "./src/assets/scss/iframe.scss" as *;`
- }
- }
- },
- server: {
- host: '0.0.0.0',
- port: 19017,
- open: true,
- proxy: {
- '/api': {
- // 这里的'/api'表示需要转发到的接口路径前缀
- target, // 将请求转发到的目标地址
- changeOrigin: true, // 支持跨域
- rewrite: (path) => path.replace(/^\/api/, '') // 去除请求路径中的'/api'前缀
- }
- }
- },
- build: {
- chunkSizeWarningLimit: 1600,
- rollupOptions: {
- output: {
- entryFileNames: `assets/[name].[hash].js`,
- chunkFileNames: `assets/[name].[hash].js`,
- assetFileNames: `assets/[name].[hash].[ext]`,
-
- }
- },
- },
- vue: {
- compilerOptions: {
- isCustomElement: (tag) => tag == 'ww-open-data' // 排除 ww-open-data
- }
- },
- resolve: {
- alias: [
- { find: "@", replacement: path.resolve(__dirname, "src") },
- { find: "@pages", replacement: path.resolve(__dirname, "src/pages") },
- {
- find: "@components",
- replacement: path.resolve(__dirname, "src/components"),
- },
- { find: "@hooks", replacement: path.resolve(__dirname, "src/hooks") },
- { find: "@utility", replacement: path.resolve(__dirname, "src/utility") },
- { find: "@store", replacement: path.resolve(__dirname, "src/store") },
- { find: "@lang", replacement: path.resolve(__dirname, "src/lang") },
- { find: "@common", replacement: path.resolve(__dirname, "src/common") },
- { find: "@api", replacement: path.resolve(__dirname, "src/api") },
- ],
- },
- });
|