index.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import path from "path"
  2. const config = {
  3. projectName: 'new-taro-mini-book',
  4. date: '2024-8-26',
  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. '@src': path.resolve(__dirname, '..', 'src'),
  29. },
  30. weapp: {
  31. module: {
  32. postcss: {
  33. // css modules 功能开关与相关配置
  34. cssModules: {
  35. enable: true, // 默认为 false,如需使用 css modules 功能,则设为 true
  36. config: {
  37. namingPattern: 'module', // 转换模式,取值为 global/module,下文详细说明
  38. generateScopedName: '[name]__[local]___[hash:base64:5]',
  39. },
  40. }
  41. }
  42. },
  43. },
  44. mini: {
  45. postcss: {
  46. pxtransform: {
  47. enable: true,
  48. config: {
  49. }
  50. },
  51. url: {
  52. enable: true,
  53. config: {
  54. limit: 1024 // 设定转换尺寸上限
  55. }
  56. },
  57. cssModules: {
  58. enable: true, // 默认为 false,如需使用 css modules 功能,则设为 true
  59. config: {
  60. namingPattern: 'module', // 转换模式,取值为 global/module
  61. generateScopedName: '[name]__[local]___[hash:base64:5]'
  62. }
  63. }
  64. }
  65. },
  66. h5: {
  67. publicPath: '/',
  68. staticDirectory: 'static',
  69. postcss: {
  70. autoprefixer: {
  71. enable: true,
  72. config: {
  73. }
  74. },
  75. cssModules: {
  76. enable: true, // 默认为 false,如需使用 css modules 功能,则设为 true
  77. config: {
  78. namingPattern: 'module', // 转换模式,取值为 global/module
  79. generateScopedName: '[name]__[local]___[hash:base64:5]'
  80. }
  81. }
  82. }
  83. }
  84. }
  85. module.exports = function (merge) {
  86. if (process.env.NODE_ENV === 'development') {
  87. return merge({}, config, require('./dev'))
  88. }
  89. return merge({}, config, require('./prod'))
  90. }