index.js 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. compile: {
  39. exclude: [
  40. path.resolve(__dirname, '..', 'src/native/')
  41. ]
  42. },
  43. postcss: {
  44. pxtransform: {
  45. enable: true,
  46. config: {
  47. }
  48. },
  49. url: {
  50. enable: true,
  51. config: {
  52. limit: 1024 // 设定转换尺寸上限
  53. }
  54. },
  55. cssModules: {
  56. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  57. config: {
  58. namingPattern: 'module', // 转换模式,取值为 global/module
  59. generateScopedName: '[name]__[local]___[hash:base64:5]'
  60. }
  61. }
  62. }
  63. },
  64. h5: {
  65. publicPath: '/',
  66. staticDirectory: 'static',
  67. postcss: {
  68. autoprefixer: {
  69. enable: true,
  70. config: {
  71. }
  72. },
  73. cssModules: {
  74. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  75. config: {
  76. namingPattern: 'module', // 转换模式,取值为 global/module
  77. generateScopedName: '[name]__[local]___[hash:base64:5]'
  78. }
  79. }
  80. }
  81. }
  82. }
  83. module.exports = function (merge) {
  84. if (process.env.NODE_ENV === 'development') {
  85. return merge({}, config, require('./dev'))
  86. }
  87. return merge({}, config, require('./prod'))
  88. }