index.js 2.0KB

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