index.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. const path = require('path');
  2. const config = {
  3. projectName: 'hola',
  4. date: '2023-10-5',
  5. designWidth: 750,
  6. deviceRatio: {
  7. 640: 2.34 / 2,
  8. 750: 1,
  9. 828: 1.81 / 2
  10. },
  11. sourceRoot: 'src',
  12. outputRoot: 'dist',
  13. plugins: [],
  14. defineConstants: {
  15. },
  16. copy: {
  17. patterns: [
  18. ],
  19. options: {
  20. }
  21. },
  22. framework: 'react',
  23. compiler: 'webpack5',
  24. cache: {
  25. enable: false // Webpack 持久化缓存配置,建议开启。默认配置请参考:https://docs.taro.zone/docs/config-detail#cache
  26. },
  27. alias: {
  28. '@components': path.resolve(__dirname, '..', 'src/components'),
  29. '@assets': path.resolve(__dirname, '..', 'src/assets'),
  30. '@utils': path.resolve(__dirname, '..', 'src/utils'),
  31. '@features': path.resolve(__dirname, '..', 'src/features'),
  32. },
  33. mini: {
  34. postcss: {
  35. pxtransform: {
  36. enable: true,
  37. config: {
  38. }
  39. },
  40. url: {
  41. enable: true,
  42. config: {
  43. limit: 1024 // 设定转换尺寸上限
  44. }
  45. },
  46. cssModules: {
  47. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  48. config: {
  49. namingPattern: 'module', // 转换模式,取值为 global/module
  50. generateScopedName: '[name]__[local]___[hash:base64:5]'
  51. }
  52. }
  53. }
  54. },
  55. h5: {
  56. publicPath: '/',
  57. staticDirectory: 'static',
  58. postcss: {
  59. autoprefixer: {
  60. enable: true,
  61. config: {
  62. }
  63. },
  64. cssModules: {
  65. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  66. config: {
  67. namingPattern: 'module', // 转换模式,取值为 global/module
  68. generateScopedName: '[name]__[local]___[hash:base64:5]'
  69. }
  70. }
  71. }
  72. },
  73. rn: {
  74. appName: 'hola',
  75. output: {
  76. ios: './ios/main.jsbundle',
  77. iosAssetsDest: './ios',
  78. android: './android/app/src/main/assets/index.android.bundle',
  79. androidAssetsDest: './android/app/src/main/res',
  80. // iosSourceMapUrl: '',
  81. iosSourcemapOutput: './ios/main.map',
  82. // iosSourcemapSourcesRoot: '',
  83. // androidSourceMapUrl: '',
  84. androidSourcemapOutput: './android/app/src/main/assets/index.android.map',
  85. // androidSourcemapSourcesRoot: '',
  86. },
  87. postcss: {
  88. cssModules: {
  89. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  90. }
  91. }
  92. }
  93. }
  94. module.exports = function (merge) {
  95. if (process.env.NODE_ENV === 'development') {
  96. return merge({}, config, require('./dev'))
  97. }
  98. return merge({}, config, require('./prod'))
  99. }