Files
yshop-pro-uniapp/vite.config.js

56 lines
1.7 KiB
JavaScript
Raw Permalink Normal View History

2023-11-14 17:21:03 +08:00
import uni from "@dcloudio/vite-plugin-uni";
import { VUE_APP_API_URL } from "./config";
2023-11-14 17:21:03 +08:00
// https://vitejs.dev/config/
export default ({mode}) => {
return {
plugins: [uni()],
server: {
https: false,
port: 10086,
proxy: {
["/yshop-api"]: {
target: VUE_APP_API_URL,
2023-11-14 17:21:03 +08:00
ws: false,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/yshop-api/, ''),
2023-11-14 17:21:03 +08:00
},
}
2023-11-14 17:21:03 +08:00
},
css: {
/* CSS 预处理器 */
preprocessorOptions: {
scss: {
additionalData: '@import "@/style/main.scss";'
}
}
},
// 打包相关
build: {
sourcemap: false, //构建后是否生成 source map 文件
cssCodeSplit: true,// 启用/禁用 CSS 代码拆分
assetsInlineLimit: 4096, // 图片转base64编码的阈值
rollupOptions: {
output: {
// 拆分包
// manualChunks(id){
// if (id.includes("node_modules")) {
// // 让每个插件都打包成独立的文件
// return id.toString().split("node_modules/")[1].split("/")[0].toString();
// }
// }
}
},
// 去除控制台打印
// minify: 'terser',
// terserOptions: {
// compress: {
// drop_console: false,
// drop_debugger: false
// }
// }
2023-11-14 17:21:03 +08:00
}
}
}