index.js 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. '@/native': path.resolve(__dirname, '..', 'src/native'),
  27. '@/pages': path.resolve(__dirname, '..', 'src/pages'),
  28. },
  29. copy: {
  30. patterns: [
  31. // { from: 'src/native/', to: 'dist/native/' },
  32. ],
  33. options: {
  34. }
  35. },
  36. framework: 'react',
  37. mini: {
  38. postcss: {
  39. pxtransform: {
  40. enable: true,
  41. config: {
  42. }
  43. },
  44. url: {
  45. enable: true,
  46. config: {
  47. limit: 1024 // 设定转换尺寸上限
  48. }
  49. },
  50. cssModules: {
  51. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  52. config: {
  53. namingPattern: 'module', // 转换模式,取值为 global/module
  54. generateScopedName: '[name]__[local]___[hash:base64:5]'
  55. }
  56. }
  57. }
  58. },
  59. h5: {
  60. publicPath: '/',
  61. staticDirectory: 'static',
  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. }
  78. module.exports = function (merge) {
  79. if (process.env.NODE_ENV === 'development') {
  80. return merge({}, config, require('./dev'))
  81. }
  82. return merge({}, config, require('./prod'))
  83. }