1 Star 1 Fork 1

huying10 / microApp-vue3-vite

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
vite.config.js 1.55 KB
一键复制 编辑 原始数据 按行查看 历史
huying 提交于 2022-09-14 10:22 . init
import qiankun, { transformAssetUrl } from "@sh-winter/vite-plugin-qiankun";
import { defineConfig } from "vite";
import { resolve } from "path";
import vue from "@vitejs/plugin-vue";
import { name as packageName } from "./package.json";
function pathResolve(dir) {
return resolve(process.cwd(), ".", dir);
}
/**
* 在 Vite 的 API 中,在开发环境下 command 的值为 serve
* (在 CLI 中,vite dev 和 vite serve 是 vite 的别名),
* 而在生产环境下为 build(vite build)
*/
export default defineConfig(({ command, mode }) => {
const port = 8081; // 可自定义本地开发端口
const isDev = mode === "development"; // 开发环境下
console.log("当前环境vite:", mode);
return {
// publicDir: isDev ? "/" : "/child/vite-vue3", // 独立部署的时候,默认'/'就行,不需要配置,Nginx里面允许跨域即可
resolve: {
alias: [
// @/xxxx => src/xxxx
{
find: /@\//,
replacement: pathResolve("src") + "/",
},
],
},
server: {
host: "0.0.0.0",
port,
// 允许跨域
cors: true,
// 本地开发,代理配置项
// proxy: {
// '/api': {
// target: 'http://xxx.xx.xx.xx',
// changeOrigin: true,
// rewrite: (path) => path.replace(/^\/api/, '')
// },
// }
},
plugins: [
vue({
template: {
compilerOptions: {
nodeTransforms: [transformAssetUrl],
},
},
}),
qiankun({ packageName }),
],
};
});
1
https://gitee.com/huying10/micro-app-vue3-vite.git
git@gitee.com:huying10/micro-app-vue3-vite.git
huying10
micro-app-vue3-vite
microApp-vue3-vite
master

搜索帮助