index.js 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. { from: 'src/native/', to: 'dist/native/' },
  31. ],
  32. options: {
  33. }
  34. },
  35. framework: 'react',
  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. postcss: {
  62. autoprefixer: {
  63. enable: true,
  64. config: {
  65. }
  66. },
  67. cssModules: {
  68. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  69. config: {
  70. namingPattern: 'module', // 转换模式,取值为 global/module
  71. generateScopedName: '[name]__[local]___[hash:base64:5]'
  72. }
  73. }
  74. }
  75. }
  76. }
  77. module.exports = function (merge) {
  78. if (process.env.NODE_ENV === 'development') {
  79. return merge({}, config, require('./dev'))
  80. }
  81. return merge({}, config, require('./prod'))
  82. }