代码拉取完成,页面将自动刷新
同步操作将从 三线程序猿/vue-next-uniapp 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/*
* @Description:
* @Author: shuliang
* @Date: 2022-06-21 15:58:08
* @LastEditTime: 2022-06-28 08:39:17
* @LastEditors: shuliang
*/
import { ConfigEnv, defineConfig, loadEnv } from 'vite'
import { resolve } from 'path'
import { viteMockServe } from 'vite-plugin-mock'
import uni from '@dcloudio/vite-plugin-uni'
const pathResolve = (dir: string): any => {
return resolve(__dirname, '.', dir)
}
const alias: Record<string, string> = {
'@': pathResolve('./src/'),
}
const viteConfig = defineConfig((mode: ConfigEnv) => {
const env = loadEnv(mode.mode, process.cwd())
const localEnabled: boolean = (env.VITE_USE_MOCK as unknown as boolean) || false
const prodEnabled: boolean = (env.USE_CHUNK_MOCK as unknown as boolean) || false
return {
plugins: [
uni(),
viteMockServe({
// ↓解析根目录下的mock文件夹
mockPath: 'mock',
localEnabled: localEnabled, // 开发打包开关
prodEnabled: prodEnabled, // 生产打包开关
supportTs: true, // 打开后,可以读取 ts 文件模块。 请注意,打开后将无法监视.js 文件。
watchFiles: true, // 监视文件更改
}),
],
root: process.cwd(),
resolve: { alias },
base: mode.command === 'serve' ? './' : env.VITE_PUBLIC_PATH,
server: {
host: '0.0.0.0',
port: env.VITE_PORT as unknown as number,
open: env.VITE_OPEN,
proxy: {
[env.VITE_BASE]: {
target: 'https://gitee.com',
ws: true,
changeOrigin: true,
rewrite: (path) => path.replace(new RegExp(env.VITE_BASE, 'g'), '/'),
},
},
},
build: {
outDir: 'dist',
minify: 'terser',
sourcemap: false,
chunkSizeWarningLimit: 1500,
rollupOptions: {
output: {
entryFileNames: `assets/[name].${new Date().getTime()}.js`,
chunkFileNames: `assets/[name].${new Date().getTime()}.js`,
assetFileNames: `assets/[name].${new Date().getTime()}.[ext]`,
compact: true,
manualChunks: {
vue: ['vue', 'vue-router', 'vuex'],
echarts: ['echarts'],
},
},
},
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
},
ie8: true,
output: {
comments: true,
},
},
},
css: {
postcss: {
plugins: [
{
postcssPlugin: 'internal:charset-removal',
AtRule: {
charset: (atRule) => {
if (atRule.name === 'charset') {
atRule.remove()
}
},
},
},
],
},
},
}
})
export default viteConfig
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。