1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. const path = require('path')
  2. const config = {
  3. projectName: 'miniapp',
  4. date: '2020-11-24',
  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. copy: {
  17. patterns: [
  18. ],
  19. options: {
  20. }
  21. },
  22. framework: 'react',
  23. mini: {
  24. postcss: {
  25. pxtransform: {
  26. enable: true,
  27. config: {
  28. }
  29. },
  30. url: {
  31. enable: true,
  32. config: {
  33. limit: 1024 // 设定转换尺寸上限
  34. }
  35. },
  36. cssModules: {
  37. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  38. config: {
  39. namingPattern: 'module', // 转换模式,取值为 global/module
  40. generateScopedName: '[name]__[local]___[hash:base64:5]'
  41. }
  42. }
  43. },
  44. webpackChain (chain, webpack) {
  45. chain.plugin('analyzer')
  46. .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
  47. }
  48. },
  49. h5: {
  50. publicPath: '/',
  51. staticDirectory: 'static',
  52. postcss: {
  53. autoprefixer: {
  54. enable: true,
  55. config: {
  56. }
  57. },
  58. cssModules: {
  59. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  60. config: {
  61. namingPattern: 'module', // 转换模式,取值为 global/module
  62. generateScopedName: '[name]__[local]___[hash:base64:5]'
  63. }
  64. }
  65. }
  66. },
  67. alias: {
  68. '@/assets': path.resolve(__dirname, '..', 'src/assets'),
  69. '@/components': path.resolve(__dirname, '..', 'src/components'),
  70. '@/layouts': path.resolve(__dirname, '..', 'src/layouts'),
  71. '@/store': path.resolve(__dirname, '..', 'src/store'),
  72. '@/utils': path.resolve(__dirname, '..', 'src/utils')
  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. }