mirror of
https://gitee.com/fantastic-admin/basic.git
synced 2024-11-29 18:48:31 +08:00
环境变量里增加 mock 开关,解决生产环境上传组件无法上传的问题
This commit is contained in:
parent
255534d23d
commit
64884b2c35
@ -7,6 +7,8 @@ VITE_APP_API_BASEURL = /
|
||||
# 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空
|
||||
VITE_APP_DEBUG_TOOL =
|
||||
|
||||
# 是否在打包时启用 Mock
|
||||
VITE_BUILD_MOCK = false
|
||||
# 是否在打包时生成 sourcemap
|
||||
VITE_BUILD_SOURCEMAP = false
|
||||
# 是否在打包时删除 console 代码
|
||||
|
@ -7,11 +7,11 @@ VITE_APP_API_BASEURL = /
|
||||
# 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空
|
||||
VITE_APP_DEBUG_TOOL =
|
||||
|
||||
# 是否在打包时启用 Mock
|
||||
VITE_BUILD_MOCK = true
|
||||
# 是否在打包时生成 sourcemap
|
||||
VITE_BUILD_SOURCEMAP = true
|
||||
# 是否在打包时删除 console 代码
|
||||
VITE_BUILD_DROP_CONSOLE = true
|
||||
# 是否在打包时开启压缩,支持 gzip 和 brotli
|
||||
VITE_BUILD_COMPRESS = gzip,brotli
|
||||
# 是否在打包时候生成PWA
|
||||
VITE_BUILD_PWA = false
|
||||
|
@ -23,7 +23,7 @@ export default function createVitePlugins(viteEnv, isBuild = false) {
|
||||
vitePlugins.push(createComponents())
|
||||
vitePlugins.push(createSetupExtend())
|
||||
vitePlugins.push(createSvgIcon(isBuild))
|
||||
vitePlugins.push(createMock())
|
||||
vitePlugins.push(createMock(viteEnv, isBuild))
|
||||
vitePlugins.push(createLayouts())
|
||||
vitePlugins.push(createPages())
|
||||
isBuild && vitePlugins.push(...createCompression(viteEnv))
|
||||
|
@ -1,8 +1,11 @@
|
||||
import { viteMockServe } from 'vite-plugin-mock'
|
||||
|
||||
export default function createMock() {
|
||||
export default function createMock(env, isBuild) {
|
||||
const { VITE_BUILD_MOCK } = env
|
||||
return viteMockServe({
|
||||
mockPath: 'src/mock',
|
||||
localEnabled: !isBuild,
|
||||
prodEnabled: isBuild && VITE_BUILD_MOCK === 'true',
|
||||
injectCode: `
|
||||
import { setupProdMockServer } from './mockProdServer';
|
||||
setupProdMockServer();
|
||||
|
Loading…
Reference in New Issue
Block a user