1 Star 0 Fork 7

vaesonshu/vue3-vite2-ts-blog-h5

forked from wall/vue3-vite2-ts-blog-h5 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
vite.config.ts 1.92 KB
一键复制 编辑 原始数据 按行查看 历史
wall 提交于 2021-09-12 16:09 . 打包部署
import { ConfigEnv, loadEnv, UserConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
import legacy from "@vitejs/plugin-legacy";
import { resolve } from "path";
import styleImport from "vite-plugin-style-import"; // 按需导入ui组件
const CWD = process.cwd(); // 项目根目录
export default ({ mode }: ConfigEnv): UserConfig => {
const { VITE_BASE_URL } = loadEnv(mode, CWD); // mode环境变量
return {
base: VITE_BASE_URL,
css: {
modules: {
localsConvention: "camelCase", // 默认只支持驼峰,修改为同时支持横线和驼峰
},
preprocessorOptions: {
scss: {
additionalData: '@import "./src/styles/index.scss";',
},
},
},
plugins: [
vue(),
vueJsx(),
legacy({
targets: ["defaults", "not IE 11"],
}),
styleImport({
// 手动导入组件
libs: [
{
libraryName: "vant",
esModule: true,
resolveStyle: (name) => {
return `vant/es/${name}/style`;
},
},
],
}),
],
resolve: {
alias: {
"@": resolve(__dirname, "src"),
},
},
build: {
target: "modules",
polyfillModulePreload: true,
outDir: "dist",
assetsDir: "static",
minify: "terser", // 混淆器
},
optimizeDeps: {
include: ["vue", "vue-router", "vant"],
exclude: ["vue-demi"],
},
server: {
host: "0.0.0.0",
port: 8089, // 设置服务启动端口号
open: true,
cors: true, // 允许跨域
// 设置代理,根据项目实际情况配置
proxy: {
"/client_api": {
target: "http://localhost:3000/client_api/",
changeOrigin: true,
secure: false,
rewrite: (path) => path.replace(/^\/client_api/, "/"),
},
},
},
};
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/vaesonshu/vue3-vite2-ts-blog-h5.git
git@gitee.com:vaesonshu/vue3-vite2-ts-blog-h5.git
vaesonshu
vue3-vite2-ts-blog-h5
vue3-vite2-ts-blog-h5
master

搜索帮助