update:分包、对接个人练习
This commit is contained in:
@@ -1,8 +1,23 @@
|
||||
import { fileURLToPath, URL } from 'node:url'
|
||||
import { readFileSync } from 'node:fs'
|
||||
|
||||
import { defineConfig } from 'vite'
|
||||
import uni from '@dcloudio/vite-plugin-uni'
|
||||
|
||||
const protobufUtf8CompatPath = fileURLToPath(new URL('./src/utils/protobufUtf8Compat.js', import.meta.url))
|
||||
|
||||
function protobufUtf8CompatPlugin() {
|
||||
return {
|
||||
name: 'protobufjs-utf8-miniprogram-compat',
|
||||
load(id) {
|
||||
const normalizedId = id.replace(/\\/g, '/')
|
||||
if (normalizedId.endsWith('/node_modules/protobufjs/src/util/utf8.js')) {
|
||||
return readFileSync(protobufUtf8CompatPath, 'utf8')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
resolve: {
|
||||
alias: {
|
||||
@@ -10,6 +25,7 @@ export default defineConfig({
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
protobufUtf8CompatPlugin(),
|
||||
uni(),
|
||||
],
|
||||
/** 构建时常量注入:__BUILD_TIME__ 在源码中展开为精确的打包时刻字符串 */
|
||||
|
||||
Reference in New Issue
Block a user