index.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. options: {
  24. }
  25. },
  26. framework: 'react',
  27. compiler: 'webpack5',
  28. cache: {
  29. enable: false // Webpack 持久化缓存配置,建议开启。默认配置请参考:https://docs.taro.zone/docs/config-detail#cache
  30. },
  31. alias:{
  32. '@src': path.resolve(__dirname, '..', 'src'),
  33. },
  34. weapp: {
  35. module: {
  36. postcss: {
  37. // css modules 功能开关与相关配置
  38. cssModules: {
  39. enable: true, // 默认为 false,如需使用 css modules 功能,则设为 true
  40. config: {
  41. namingPattern: 'module', // 转换模式,取值为 global/module,下文详细说明
  42. generateScopedName: '[name]__[local]___[hash:base64:5]',
  43. },
  44. }
  45. }
  46. },
  47. },
  48. mini: {
  49. postcss: {
  50. pxtransform: {
  51. enable: true,
  52. config: {
  53. }
  54. },
  55. url: {
  56. enable: true,
  57. config: {
  58. limit: 1024 // 设定转换尺寸上限
  59. }
  60. },
  61. cssModules: {
  62. enable: true, // 默认为 false,如需使用 css modules 功能,则设为 true
  63. config: {
  64. namingPattern: 'module', // 转换模式,取值为 global/module
  65. generateScopedName: '[name]__[local]___[hash:base64:5]'
  66. }
  67. }
  68. }
  69. },
  70. h5: {
  71. publicPath: '/',
  72. staticDirectory: 'static',
  73. postcss: {
  74. autoprefixer: {
  75. enable: true,
  76. config: {
  77. }
  78. },
  79. cssModules: {
  80. enable: true, // 默认为 false,如需使用 css modules 功能,则设为 true
  81. config: {
  82. namingPattern: 'module', // 转换模式,取值为 global/module
  83. generateScopedName: '[name]__[local]___[hash:base64:5]'
  84. }
  85. }
  86. }
  87. }
  88. }
  89. module.exports = function (merge:any) {
  90. if (process.env.NODE_ENV === 'development') {
  91. return merge({}, config, require('./dev'))
  92. }
  93. return merge({}, config, require('./prod'))
  94. }