index.js 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. const path = require('path')
  2. const config = {
  3. projectName: 'miniapp',
  4. date: '2021-5-12',
  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. alias: {
  17. '@/assets': path.resolve(__dirname, '..', 'src/assets'),
  18. '@/actions': path.resolve(__dirname, '..', 'src/actions'),
  19. '@/components': path.resolve(__dirname, '..', 'src/components'),
  20. '@/layout': path.resolve(__dirname, '..', 'src/layout'),
  21. '@/constants': path.resolve(__dirname, '..', 'src/constants'),
  22. '@/reducers': path.resolve(__dirname, '..', 'src/reducers'),
  23. '@/store': path.resolve(__dirname, '..', 'src/store'),
  24. '@/services': path.resolve(__dirname, '..', 'src/services'),
  25. '@/utils': path.resolve(__dirname, '..', 'src/utils'),
  26. '@/pages': path.resolve(__dirname, '..', 'src/pages'),
  27. },
  28. copy: {
  29. patterns: [
  30. ],
  31. options: {
  32. }
  33. },
  34. framework: 'react',
  35. mini: {
  36. postcss: {
  37. pxtransform: {
  38. enable: true,
  39. config: {
  40. }
  41. },
  42. url: {
  43. enable: true,
  44. config: {
  45. limit: 1024 // 设定转换尺寸上限
  46. }
  47. },
  48. cssModules: {
  49. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  50. config: {
  51. namingPattern: 'module', // 转换模式,取值为 global/module
  52. generateScopedName: '[name]__[local]___[hash:base64:5]'
  53. }
  54. }
  55. }
  56. },
  57. h5: {
  58. publicPath: '/',
  59. staticDirectory: 'static',
  60. postcss: {
  61. autoprefixer: {
  62. enable: true,
  63. config: {
  64. }
  65. },
  66. cssModules: {
  67. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  68. config: {
  69. namingPattern: 'module', // 转换模式,取值为 global/module
  70. generateScopedName: '[name]__[local]___[hash:base64:5]'
  71. }
  72. }
  73. }
  74. }
  75. }
  76. module.exports = function (merge) {
  77. if (process.env.NODE_ENV === 'development') {
  78. return merge({}, config, require('./dev'))
  79. }
  80. return merge({}, config, require('./prod'))
  81. }