index.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import path from '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. '@': path.resolve(__dirname, '..', 'src'), // 这样配置后 @ 可以指向 src 目录
  29. '@components': path.resolve(__dirname, '../src/components'),
  30. '@assets': path.resolve(__dirname, '..', 'src/assets'),
  31. '@utils': path.resolve(__dirname, '..', 'src/utils'),
  32. '@features': path.resolve(__dirname, '..', 'src/features'),
  33. '@services': path.resolve(__dirname, '..', 'src/services'),
  34. },
  35. mini: {
  36. miniCssExtractPluginOption: {
  37. ignoreOrder: true
  38. },
  39. postcss: {
  40. pxtransform: {
  41. enable: true,
  42. config: {
  43. }
  44. },
  45. url: {
  46. enable: true,
  47. config: {
  48. limit: 1024 // 设定转换尺寸上限
  49. }
  50. },
  51. cssModules: {
  52. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  53. config: {
  54. namingPattern: 'module', // 转换模式,取值为 global/module
  55. generateScopedName: '[name]__[local]___[hash:base64:5]'
  56. }
  57. }
  58. }
  59. },
  60. h5: {
  61. publicPath: '/',
  62. staticDirectory: 'static',
  63. postcss: {
  64. autoprefixer: {
  65. enable: true,
  66. config: {
  67. }
  68. },
  69. cssModules: {
  70. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  71. config: {
  72. namingPattern: 'module', // 转换模式,取值为 global/module
  73. generateScopedName: '[name]__[local]___[hash:base64:5]'
  74. }
  75. }
  76. }
  77. },
  78. rn: {
  79. appName: 'hola',
  80. alias: {
  81. '@': path.resolve(__dirname, '..', 'src'), // 这样配置后 @ 可以指向 src 目录
  82. '@components': path.resolve(__dirname, '../src/components'),
  83. '@assets': path.resolve(__dirname, '..', 'src/assets'),
  84. '@utils': path.resolve(__dirname, '..', 'src/utils'),
  85. '@features': path.resolve(__dirname, '..', 'src/features'),
  86. '@services': path.resolve(__dirname, '..', 'src/services'),
  87. },
  88. output: {
  89. ios: './ios/main.jsbundle',
  90. iosAssetsDest: './ios',
  91. android: './android/app/src/main/assets/index.android.bundle',
  92. androidAssetsDest: './android/app/src/main/res',
  93. // iosSourceMapUrl: '',
  94. iosSourcemapOutput: './ios/main.map',
  95. // iosSourcemapSourcesRoot: '',
  96. // androidSourceMapUrl: '',
  97. androidSourcemapOutput: './android/app/src/main/assets/index.android.map',
  98. // androidSourcemapSourcesRoot: '',
  99. },
  100. postcss: {
  101. cssModules: {
  102. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  103. }
  104. }
  105. }
  106. }
  107. module.exports = function (merge) {
  108. if (process.env.NODE_ENV === 'development') {
  109. return merge({}, config, require('./dev'))
  110. }
  111. return merge({}, config, require('./prod'))
  112. }