1 Star 6 Fork 5

xLong1029/xlong-big-data

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
vite.config.js 2.65 KB
一键复制 编辑 原始数据 按行查看 历史
xLong1029 提交于 2022-10-05 22:38 . 修改打包配置
import { defineConfig, loadEnv } from 'vite';
import path from "path";
import vue from '@vitejs/plugin-vue';
import AutoImport from 'unplugin-auto-import/vite'
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
import { viteMockServe } from "vite-plugin-mock";
import autoprefixer from "autoprefixer";
import settings from "./src/settings";
const port = settings.webPort;
// 获取打包文件
function getOutputDir(env) {
let dir = "xLongBigData";
switch (env.VITE_APP_ENV) {
case "test":
dir = "xLongBigDataTest";
break;
case "release":
dir = "xLongBigDataRelease";
break;
}
return dir;
}
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
return {
base: mode === 'production' ? "./" : "/",
build: {
outDir: getOutputDir(env),
// 修改打包块限制大小
chunkSizeWarningLimit: 10000
},
plugins: [
vue(),
AutoImport({
resolvers: [
ElementPlusResolver({
importStyle: "sass",
})
],
}),
Components({
resolvers: [
ElementPlusResolver({
importStyle: "sass",
}),
],
}),
viteMockServe({
mockPath: "./src/mock", // mock地址
supportTs: false, // 如果使用 js发开,则需要配置 supportTs 为 false
watchFiles: true, // 监视文件更改
prodEnabled: env.VITE_USE_MOCK,
// mock生产环境配置
injectCode: `
import { setupProdMockServer } from "./mock/mock-server.js";
setupProdMockServer();
`
})
],
// 引入第三方的配置
optimizeDeps: {
include: [
"element-plus/lib/locale/lang/zh-cn",
],
},
server: {
hmr: true,
// 使用IP启动项目
host: "0.0.0.0",
// 配置启用的端口号
port,
// 是否开启https
https: false,
},
resolve: {
alias: {
"@/": `${path.resolve(__dirname, "src")}/`
},
},
// 全局使用
css: {
preprocessorOptions: {
scss: {
additionalData: `@use "@/styles/variables.scss" as *;`,
},
},
postcss: {
plugins: [{
postcssPlugin: 'internal:charset-removal',
AtRule: {
// 去除"@charset" must be the first警告
charset: (atRule) => {
if (atRule.name === 'charset') {
atRule.remove();
}
}
}
},
autoprefixer],
},
}
}
})
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xlong1029/xlong-big-data.git
[email protected]:xlong1029/xlong-big-data.git
xlong1029
xlong-big-data
xlong-big-data
main

搜索帮助