index.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. const path = require("path");
  2. const config = {
  3. projectName: 'taro-pet',
  4. date: '2022-12-17',
  5. alias: {
  6. "@": path.resolve(__dirname, "../src")
  7. },
  8. designWidth: 750,
  9. deviceRatio: {
  10. 640: 2.34 / 2,
  11. 750: 1,
  12. 828: 1.81 / 2
  13. },
  14. sourceRoot: 'src',
  15. outputRoot: 'dist',
  16. plugins: [],
  17. sass: {
  18. resource: [
  19. path.resolve(__dirname, '..', 'src/style/variable.scss'),
  20. path.resolve(__dirname, '..', 'src/style/mixin.scss'),
  21. ]
  22. },
  23. defineConstants: {
  24. },
  25. copy: {
  26. patterns: [
  27. ],
  28. options: {
  29. }
  30. },
  31. framework: 'react',
  32. compiler: 'webpack5',
  33. cache: {
  34. enable: false // Webpack 持久化缓存配置,建议开启。默认配置请参考:https://docs.taro.zone/docs/config-detail#cache
  35. },
  36. mini: {
  37. postcss: {
  38. pxtransform: {
  39. enable: true,
  40. config: {
  41. }
  42. },
  43. url: {
  44. enable: true,
  45. config: {
  46. limit: 1024 // 设定转换尺寸上限
  47. }
  48. },
  49. cssModules: {
  50. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  51. config: {
  52. namingPattern: 'module', // 转换模式,取值为 global/module
  53. generateScopedName: '[name]__[local]___[hash:base64:5]'
  54. }
  55. }
  56. }
  57. },
  58. h5: {
  59. publicPath: '/',
  60. staticDirectory: 'static',
  61. esnextModules: ["@taroify"],
  62. postcss: {
  63. autoprefixer: {
  64. enable: true,
  65. config: {
  66. }
  67. },
  68. cssModules: {
  69. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  70. config: {
  71. namingPattern: 'module', // 转换模式,取值为 global/module
  72. generateScopedName: '[name]__[local]___[hash:base64:5]'
  73. }
  74. }
  75. }
  76. },
  77. rn: {
  78. appName: 'taroDemo',
  79. postcss: {
  80. cssModules: {
  81. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  82. }
  83. }
  84. }
  85. }
  86. module.exports = function (merge) {
  87. if (process.env.NODE_ENV === 'development') {
  88. return merge({}, config, require('./dev'))
  89. }
  90. return merge({}, config, require('./prod'))
  91. }