使用云打包的时候卡在编译阶段,但是编译是已经编译成功了。可以看我截图的控制台输出
vite.config.js 配置
import {
defineConfig
} from "vite";
import uni from "@dcloudio/vite-plugin-uni";
// import vitePluginReplaceUniappConfig from "vite-plugin-uni-pages-config"
import vitePluginReplaceUniappConfig from './core/utils/PageSubpage.js'
import {
NodeGlobalsPolyfillPlugin
} from '@esbuild-plugins/node-globals-polyfill'
// console.log("当前用户(condition中文件名用此名字): ", process.env.USER)
let node_env = process.env.NODE_ENV;
let uniPlugin = uni();
console.log(process.env.NODE_ENV, 'process.env.NODE_ENV;', process.env.NODE_ENV == 'production' ? 'global' :
'globalThis')
export default defineConfig({
plugins: [
uniPlugin,
vitePluginReplaceUniappConfig([{
node_env, //是发布还是调试
dir: __dirname + "/core/sysConfig/pagesJson/", // 配置文件所在目录
replaceFile: __dirname + "/pages.json", //生成的文件路径
rootDir: process.env.UNI_INPUT_DIR, // 项目根目录
user: process.env.UER, //hbuilderx登录用户名
watchDirs: [`${__dirname}/pages/`, `${__dirname}/core/base/`],
// watchDir: true //是否需要监听配置文件变更,热部署 默认 true
}]),
],
optimizeDeps: {
esbuildOptions: {
// Node.js global to browser globalThis
define: {
global: 'globalThis',
// global: 'global',
},
// Enable esbuild polyfill plugins
plugins: [
NodeGlobalsPolyfillPlugin({
buffer: true
})
]
}
},
build: {
minify: 'terser',
terserOptions: {
compress: {
//生产环境时移除console
drop_console: true,
drop_debugger: true,
},
},
commonjsOptions: {
transformMixedEsModules: true
}
},
});