const path = require('path'); const config = { projectName: 'miniprogram', date: '2026-8-20', designWidth: 750, deviceRatio: { 640: 2.34 / 2, 750: 1, 375: 2, 828: 1.81 }, sourceRoot: 'src', outputRoot: 'dist', plugins: [], alias: { '@': path.resolve(__dirname, '..', 'src') }, defineConstants: { // 构建时可覆盖 API 基址:TARO_APP_API_BASE=http://192.168.1.3:8090 yarn dev:weapp 'process.env.TARO_APP_API_BASE': JSON.stringify(process.env.TARO_APP_API_BASE || ''), }, copy: { patterns: [], options: {} }, framework: 'react', compiler: { type: 'webpack5', prebundle: { enable: false } }, cache: { enable: false }, mini: { postcss: { pxtransform: { enable: true, config: {} }, // limit 调高:内嵌像素字体等小体积资源为 base64,避免运行时路径解析问题 url: { enable: true, config: { limit: 300000 } }, cssModules: { enable: false } } }, h5: { publicPath: '/', staticDirectory: 'static', postcss: { autoprefixer: { enable: true, config: {} }, cssModules: { enable: false } } } }; module.exports = function (merge) { if (process.env.NODE_ENV === 'development') { return merge({}, config, require('./dev')); } return merge({}, config, require('./prod')); };