Merge branch 'base' into i18n
This commit is contained in:
commit
3c32791ab7
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "unibest",
|
"name": "unibest",
|
||||||
"type": "commonjs",
|
"type": "commonjs",
|
||||||
"version": "2.5.3",
|
"version": "2.5.4",
|
||||||
"description": "unibest - 最好的 uniapp 开发模板",
|
"description": "unibest - 最好的 uniapp 开发模板",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "feige996",
|
"name": "feige996",
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
"@dcloudio/types",
|
"@dcloudio/types",
|
||||||
"@uni-helper/uni-types",
|
"@uni-helper/uni-types",
|
||||||
"@types/wechat-miniprogram",
|
"@types/wechat-miniprogram",
|
||||||
"wot-design-uni/global.d.ts"
|
"wot-design-uni/global.d.ts",
|
||||||
|
"z-paging/types"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"vueCompilerOptions": {
|
"vueCompilerOptions": {
|
||||||
|
39
vite-plugins/copyNativeRes.ts
Normal file
39
vite-plugins/copyNativeRes.ts
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import fs from 'fs-extra'
|
||||||
|
import path from 'path'
|
||||||
|
|
||||||
|
export function copyNativeRes() {
|
||||||
|
const waitPath = path.resolve(__dirname, '../src/nativeResources')
|
||||||
|
const buildPath = path.resolve(
|
||||||
|
__dirname,
|
||||||
|
'../dist',
|
||||||
|
process.env.NODE_ENV === 'production' ? 'build' : 'dev',
|
||||||
|
process.env.UNI_PLATFORM!,
|
||||||
|
'nativeResources',
|
||||||
|
)
|
||||||
|
|
||||||
|
return {
|
||||||
|
enforce: 'post',
|
||||||
|
async writeBundle() {
|
||||||
|
try {
|
||||||
|
// 检查源目录是否存在
|
||||||
|
const sourceExists = await fs.pathExists(waitPath)
|
||||||
|
if (!sourceExists) {
|
||||||
|
console.warn(`[copyNativeRes] 警告:源目录 "${waitPath}" 不存在,跳过复制操作。`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确保目标目录及中间目录存在
|
||||||
|
await fs.ensureDir(buildPath)
|
||||||
|
console.log(`[copyNativeRes] 确保目标目录存在:${buildPath}`)
|
||||||
|
|
||||||
|
// 执行文件夹复制
|
||||||
|
await fs.copy(waitPath, buildPath)
|
||||||
|
console.log(
|
||||||
|
`[copyNativeRes] 成功将 nativeResources 目录中的资源移动到构建目录:${buildPath}`,
|
||||||
|
)
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`[copyNativeRes] 复制资源失败:`, error)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
@ -17,6 +17,7 @@ import UnoCSS from 'unocss/vite'
|
|||||||
import AutoImport from 'unplugin-auto-import/vite'
|
import AutoImport from 'unplugin-auto-import/vite'
|
||||||
import { visualizer } from 'rollup-plugin-visualizer'
|
import { visualizer } from 'rollup-plugin-visualizer'
|
||||||
import ViteRestart from 'vite-plugin-restart'
|
import ViteRestart from 'vite-plugin-restart'
|
||||||
|
import { copyNativeRes } from './vite-plugins/copyNativeRes'
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default ({ command, mode }) => {
|
export default ({ command, mode }) => {
|
||||||
@ -97,13 +98,15 @@ export default ({ command, mode }) => {
|
|||||||
},
|
},
|
||||||
// 打包分析插件,h5 + 生产环境才弹出
|
// 打包分析插件,h5 + 生产环境才弹出
|
||||||
UNI_PLATFORM === 'h5' &&
|
UNI_PLATFORM === 'h5' &&
|
||||||
mode === 'production' &&
|
mode === 'production' &&
|
||||||
visualizer({
|
visualizer({
|
||||||
filename: './node_modules/.cache/visualizer/stats.html',
|
filename: './node_modules/.cache/visualizer/stats.html',
|
||||||
open: true,
|
open: true,
|
||||||
gzipSize: true,
|
gzipSize: true,
|
||||||
brotliSize: true,
|
brotliSize: true,
|
||||||
}),
|
}),
|
||||||
|
// 只有在 app 平台时才启用 copyNativeRes 插件
|
||||||
|
UNI_PLATFORM === 'app' && copyNativeRes(),
|
||||||
],
|
],
|
||||||
define: {
|
define: {
|
||||||
__UNI_PLATFORM__: JSON.stringify(UNI_PLATFORM),
|
__UNI_PLATFORM__: JSON.stringify(UNI_PLATFORM),
|
||||||
@ -133,12 +136,12 @@ export default ({ command, mode }) => {
|
|||||||
// 仅 H5 端生效,其他端不生效(其他端走build,不走devServer)
|
// 仅 H5 端生效,其他端不生效(其他端走build,不走devServer)
|
||||||
proxy: JSON.parse(VITE_APP_PROXY)
|
proxy: JSON.parse(VITE_APP_PROXY)
|
||||||
? {
|
? {
|
||||||
[VITE_APP_PROXY_PREFIX]: {
|
[VITE_APP_PROXY_PREFIX]: {
|
||||||
target: VITE_SERVER_BASEURL,
|
target: VITE_SERVER_BASEURL,
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: (path) => path.replace(new RegExp(`^${VITE_APP_PROXY_PREFIX}`), ''),
|
rewrite: (path) => path.replace(new RegExp(`^${VITE_APP_PROXY_PREFIX}`), ''),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user