index.ts 3.6 KB

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