123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- import { defineConfig, loadEnv } from "vite";
- import uni from "@dcloudio/vite-plugin-uni";
- import path from "path";
- // https://vitejs.dev/config/
- export default defineConfig(({ mode }) => {
- return {
- base: "./", //等同於 assetsPublicPath :'./'
- plugins: [uni(),
- { // 自定义插件禁用vite:vue插件的devToolsEnabled,强制编译 vue 模板时 inline 为 true
- name: 'fix-vite-plugin-vue',
- configResolved(config) {
- const plugin = config.plugins.find((p) => p.name === 'vite:vue')
- if (plugin && plugin.api && plugin.api.options) {
- plugin.api.options.devToolsEnabled = false
- }
- },
- },
- ],
- resolve: {
- alias: {
- '@': path.resolve(__dirname, './src/'),
- }
- },
- css: {
- preprocessorOptions: {
- scss: {
- preprocessorOptions: `@import "@/static/css/common.scss";`
- },
- }
- },
- server: {
- host: '0.0.0.0',
- port: 8081,
- https: false,
- proxy: {
- '/api': {
- target: loadEnv(mode, process.cwd()).VITE_APP_URL_H5,
- changeOrigin: true,
- rewrite: (path) => path.replace(/^\/api/, '')
- }
- }
- }
- }
- });
|