index.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. from: 'src/components/novelPlugin/customParagraph',
  20. to: 'dist/components/novelPlugin/customParagraph'
  21. },
  22. {
  23. from: 'src/components/novelPlugin/fullScreen',
  24. to: 'dist/components/novelPlugin/fullScreen'
  25. }
  26. ],
  27. options: {
  28. }
  29. },
  30. framework: 'react',
  31. compiler: 'webpack5',
  32. cache: {
  33. enable: false // Webpack 持久化缓存配置,建议开启。默认配置请参考:https://docs.taro.zone/docs/config-detail#cache
  34. },
  35. alias:{
  36. '@src': path.resolve(__dirname, '..', 'src'),
  37. },
  38. weapp: {
  39. module: {
  40. postcss: {
  41. // css modules 功能开关与相关配置
  42. cssModules: {
  43. enable: true, // 默认为 false,如需使用 css modules 功能,则设为 true
  44. config: {
  45. namingPattern: 'module', // 转换模式,取值为 global/module,下文详细说明
  46. generateScopedName: '[name]__[local]___[hash:base64:5]',
  47. },
  48. }
  49. }
  50. },
  51. },
  52. mini: {
  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: true, // 默认为 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: true, // 默认为 false,如需使用 css modules 功能,则设为 true
  85. config: {
  86. namingPattern: 'module', // 转换模式,取值为 global/module
  87. generateScopedName: '[name]__[local]___[hash:base64:5]'
  88. }
  89. }
  90. }
  91. }
  92. }
  93. module.exports = function (merge:any) {
  94. if (process.env.NODE_ENV === 'development') {
  95. return merge({}, config, require('./dev'))
  96. }
  97. return merge({}, config, require('./prod'))
  98. }