Search
Close this search box.

wordpress vue3 vite 项目跨域解决方法

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  build: {
    rollupOptions: {
      output: {
        // 指定 chunk 文件名(含导出的代码)
        //chunkFileNames: 'js/[name].js',
        // 指定静态资源文件名(不含导出的代码)
        //assetFileNames: 'assets/[name].[ext]',
        entryFileNames: "index.js",
        assetFileNames: "[name][extname]",
        chunkFileNames: "[name].js",
      },
    },
  },
  server: {
    port:5173,
    strictPort:true,
    hmr:{
      port:5173
    },
    proxy: {
      '/wp-admin/admin-ajax.php': {
        target: 'http://127.0.0.6',
        changeOrigin: true,
        ws:true,
        rewrite(path){
          return path;
        }
      },
    }
  }
});

发表评论

Optimized by WPJAM Basic