index.ts 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. import path from 'path';
  2. import { WX_VERSION } from './env';
  3. const CIPluginFn = {
  4. weapp: {
  5. appid: 'wxe1396d16d519e16b',
  6. privateKeyPath: 'ci/ca/private.wxe1396d16d519e16b.key',
  7. robot: 1,
  8. },
  9. version: WX_VERSION,
  10. desc: '自动发布测试'
  11. };
  12. const config = {
  13. projectName: 'hola',
  14. date: '2023-10-5',
  15. designWidth: 750,
  16. deviceRatio: {
  17. 640: 2.34 / 2,
  18. 750: 1,
  19. 828: 1.81 / 2
  20. },
  21. sourceRoot: 'src',
  22. outputRoot: 'dist',
  23. plugins: [['@tarojs/plugin-mini-ci', CIPluginFn]],
  24. defineConstants: {
  25. },
  26. copy: {
  27. patterns: [
  28. // {
  29. // from: `node_modules/tdesign-miniprogram-taro/miniprogram_dist/`,
  30. // to: `dist/miniprogram_npm/tdesign-miniprogram/`,
  31. // ignore: ['*.ts', '*.map', 'type.js']
  32. // },
  33. ],
  34. options: {
  35. }
  36. },
  37. framework: 'react',
  38. compiler: 'webpack5',
  39. cache: {
  40. enable: false // Webpack 持久化缓存配置,建议开启。默认配置请参考:https://docs.taro.zone/docs/config-detail#cache
  41. },
  42. alias: {
  43. '@': path.resolve(__dirname, '..', 'src'), // 这样配置后 @ 可以指向 src 目录
  44. '@components': path.resolve(__dirname, '../src/components'),
  45. '@assets': path.resolve(__dirname, '..', 'src/assets'),
  46. '@utils': path.resolve(__dirname, '..', 'src/utils'),
  47. '@features': path.resolve(__dirname, '..', 'src/features'),
  48. '@services': path.resolve(__dirname, '..', 'src/services'),
  49. },
  50. mini: {
  51. miniCssExtractPluginOption: {
  52. ignoreOrder: true
  53. },
  54. postcss: {
  55. pxtransform: {
  56. enable: true,
  57. config: {
  58. }
  59. },
  60. url: {
  61. enable: true,
  62. config: {
  63. limit: 1024 // 设定转换尺寸上限
  64. }
  65. },
  66. cssModules: {
  67. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  68. config: {
  69. namingPattern: 'module', // 转换模式,取值为 global/module
  70. generateScopedName: '[name]__[local]___[hash:base64:5]'
  71. }
  72. }
  73. }
  74. },
  75. h5: {
  76. publicPath: '/',
  77. staticDirectory: 'static',
  78. postcss: {
  79. autoprefixer: {
  80. enable: true,
  81. config: {
  82. }
  83. },
  84. cssModules: {
  85. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  86. config: {
  87. namingPattern: 'module', // 转换模式,取值为 global/module
  88. generateScopedName: '[name]__[local]___[hash:base64:5]'
  89. }
  90. }
  91. }
  92. },
  93. rn: {
  94. appName: 'taroDemo',
  95. alias: {
  96. '@': path.resolve(__dirname, '..', 'src'), // 这样配置后 @ 可以指向 src 目录
  97. '@components': path.resolve(__dirname, '../src/components'),
  98. '@assets': path.resolve(__dirname, '..', 'src/assets'),
  99. '@utils': path.resolve(__dirname, '..', 'src/utils'),
  100. '@features': path.resolve(__dirname, '..', 'src/features'),
  101. '@services': path.resolve(__dirname, '..', 'src/services'),
  102. },
  103. output: {
  104. ios: './ios/main.jsbundle',
  105. iosAssetsDest: './ios',
  106. android: './android/app/src/main/assets/index.android.bundle',
  107. androidAssetsDest: './android/app/src/main/res',
  108. // iosSourceMapUrl: '',
  109. iosSourcemapOutput: './ios/main.map',
  110. // iosSourcemapSourcesRoot: '',
  111. // androidSourceMapUrl: '',
  112. androidSourcemapOutput: './android/app/src/main/assets/index.android.map',
  113. // androidSourcemapSourcesRoot: '',
  114. },
  115. postcss: {
  116. cssModules: {
  117. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  118. }
  119. }
  120. }
  121. }
  122. module.exports = function (merge) {
  123. if (process.env.NODE_ENV === 'development') {
  124. return merge({}, config, require('./dev'))
  125. }
  126. return merge({}, config, require('./prod'))
  127. }