index.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. },
  32. mini: {
  33. postcss: {
  34. pxtransform: {
  35. enable: true,
  36. config: {
  37. }
  38. },
  39. url: {
  40. enable: true,
  41. config: {
  42. limit: 1024 // 设定转换尺寸上限
  43. }
  44. },
  45. cssModules: {
  46. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  47. config: {
  48. namingPattern: 'module', // 转换模式,取值为 global/module
  49. generateScopedName: '[name]__[local]___[hash:base64:5]'
  50. }
  51. }
  52. }
  53. },
  54. h5: {
  55. publicPath: '/',
  56. staticDirectory: 'static',
  57. postcss: {
  58. autoprefixer: {
  59. enable: true,
  60. config: {
  61. }
  62. },
  63. cssModules: {
  64. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  65. config: {
  66. namingPattern: 'module', // 转换模式,取值为 global/module
  67. generateScopedName: '[name]__[local]___[hash:base64:5]'
  68. }
  69. }
  70. }
  71. },
  72. rn: {
  73. appName: 'hola',
  74. output: {
  75. ios: './ios/main.jsbundle',
  76. iosAssetsDest: './ios',
  77. android: './android/app/src/main/assets/index.android.bundle',
  78. androidAssetsDest: './android/app/src/main/res',
  79. // iosSourceMapUrl: '',
  80. iosSourcemapOutput: './ios/main.map',
  81. // iosSourcemapSourcesRoot: '',
  82. // androidSourceMapUrl: '',
  83. androidSourcemapOutput: './android/app/src/main/assets/index.android.map',
  84. // androidSourcemapSourcesRoot: '',
  85. },
  86. postcss: {
  87. cssModules: {
  88. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  89. }
  90. }
  91. }
  92. }
  93. module.exports = function (merge) {
  94. if (process.env.NODE_ENV === 'development') {
  95. return merge({}, config, require('./dev'))
  96. }
  97. return merge({}, config, require('./prod'))
  98. }