index.js 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. },
  27. copy: {
  28. patterns: [
  29. ],
  30. options: {
  31. }
  32. },
  33. framework: 'react',
  34. mini: {
  35. postcss: {
  36. pxtransform: {
  37. enable: true,
  38. config: {
  39. }
  40. },
  41. url: {
  42. enable: true,
  43. config: {
  44. limit: 1024 // 设定转换尺寸上限
  45. }
  46. },
  47. cssModules: {
  48. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  49. config: {
  50. namingPattern: 'module', // 转换模式,取值为 global/module
  51. generateScopedName: '[name]__[local]___[hash:base64:5]'
  52. }
  53. }
  54. }
  55. },
  56. h5: {
  57. publicPath: '/',
  58. staticDirectory: 'static',
  59. postcss: {
  60. autoprefixer: {
  61. enable: true,
  62. config: {
  63. }
  64. },
  65. cssModules: {
  66. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  67. config: {
  68. namingPattern: 'module', // 转换模式,取值为 global/module
  69. generateScopedName: '[name]__[local]___[hash:base64:5]'
  70. }
  71. }
  72. }
  73. }
  74. }
  75. module.exports = function (merge) {
  76. if (process.env.NODE_ENV === 'development') {
  77. return merge({}, config, require('./dev'))
  78. }
  79. return merge({}, config, require('./prod'))
  80. }