| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- const path = require('path')
- const { version } = require('../package.json')
- const CIPluginOpt = {
- weapp: {
- appid: process.env.WEAPP_ID || '微信小程序appid',
- privateKeyPath: "key/private.appid.key"
- },
- tt: {
- email: "字节小程序邮箱",
- password: "字节小程序密码"
- },
- alipay: {
- appid: "支付宝小程序appId",
- toolId: "工具id",
- privateKeyPath: "key/pkcs8-private-pem"
- },
- swan: {
- token: "鉴权需要的token令牌"
- },
- version,
- desc: "修复已知问题"
- }
- const plugins = process.env.TARO_ENV === 'weapp' ? [
- [ "@tarojs/plugin-mini-ci", CIPluginOpt ],
- [ "@tarojs/plugin-html"]
- ] : []
- const config = {
- projectName: '蚁群互动',
- date: '2025-08-01',
- designWidth: 750,
- deviceRatio: {
- 640: 2.34 / 2,
- 750: 1,
- 828: 1.81 / 2
- },
- sourceRoot: 'src',
- outputRoot: 'dist',
- plugins,
- defineConstants: {
- },
- copy: {
- patterns: [
- ],
- options: {
- }
- },
- framework: 'react',
- compiler: 'webpack5',
- mini: {
- postcss: {
- pxtransform: {
- enable: true,
- config: {
- }
- },
- url: {
- enable: true,
- config: {
- limit: 1024 // 设定转换尺寸上限
- }
- },
- cssModules: {
- enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
- config: {
- namingPattern: 'module', // 转换模式,取值为 global/module
- generateScopedName: '[name]__[local]___[hash:base64:5]'
- }
- }
- }
- },
- h5: {
- publicPath: '/h5/',
- staticDirectory: 'static',
- postcss: {
- autoprefixer: {
- enable: true,
- config: {
- }
- },
- cssModules: {
- enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
- config: {
- namingPattern: 'module', // 转换模式,取值为 global/module
- generateScopedName: '[name]__[local]___[hash:base64:5]'
- }
- }
- },
- webpackChain(chain) {
- chain.output.path(path.resolve(__dirname, '..', 'dist', 'h5'));
- // 排除 react-native 模块
- chain.resolve.alias
- .set('react-native', false)
- .set('react-native-webview', false)
- .set('@react-navigation/native', false)
- .set('react-native-signature-canvas', false)
- }
- },
- rn: {
- appName: 'taroDemo',
- bundleOptions: {
- dev: false, // 生产环境必须为 false
- lazy: false,
- minify: true, // 生产环境启用压缩
- },
- output: {
- ios: './ios/main.jsbundle',
- iosAssetsDest: './ios',
- android: './android/app/src/main/assets/index.android.bundle',
- androidAssetsDest: './android/app/src/main/res',
- // iosSourceMapUrl: '',
- iosSourcemapOutput: './ios/main.map',
- // iosSourcemapSourcesRoot: '',
- // androidSourceMapUrl: '',
- androidSourcemapOutput: './android/app/src/main/assets/index.android.map',
- // androidSourcemapSourcesRoot: '',
- },
- sass: {
- additionalData: '@use "sass:math";'
- },
- postcss: {
- cssModules:{
- enable: true,
- }
- },
- staticAssets: {
- // 配置需要复制到原生项目的静态资源
- copyOptions: {
- patterns: [
- {
- from: 'src/web-resources', // 你的静态资源源目录
- to: 'android/app/src/main/assets/web-resources', // 目标目录
- },
- ],
- },
- }
- },
- alias: {
- '@': path.resolve(__dirname, '..', 'src'),
- }
- }
- module.exports = function (merge) {
- if (process.env.NODE_ENV === 'development') {
- return merge({}, config, require('./dev'))
- }
- return merge({}, config, require('./prod'))
- }
|