index.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. const path = require('path')
  2. function resolve(name) {
  3. return path.resolve(__dirname, '..', name);
  4. }
  5. const config = {
  6. projectName: 'resource',
  7. date: '2019-9-11',
  8. designWidth: 750,
  9. deviceRatio: {
  10. '640': 2.34 / 2,
  11. '750': 1,
  12. '828': 1.81 / 2
  13. },
  14. sourceRoot: 'src',
  15. outputRoot: 'dist',
  16. plugins: {
  17. babel: {
  18. sourceMap: true,
  19. presets: [
  20. ['env', {
  21. modules: false
  22. }]
  23. ],
  24. plugins: [
  25. 'transform-decorators-legacy',
  26. 'transform-class-properties',
  27. 'transform-object-rest-spread',
  28. ]
  29. }
  30. },
  31. defineConstants: {
  32. },
  33. copy: {
  34. patterns: [
  35. ],
  36. options: {
  37. }
  38. },
  39. alias: {
  40. '@': resolve('src'),
  41. '@/utils': resolve('src/utils/index.ts'),
  42. '@/enum': resolve('src/utils/enum/index.ts'),
  43. '@/types': resolve('src/types/index.ts'),
  44. '@/constant': resolve('src/utils/constant.ts'),
  45. '@/sdk': resolve('src/utils/sdk.ts'),
  46. '@/service': resolve('src/service'),
  47. '@/store': resolve('src/store'),
  48. '@/assets': resolve('src/assets'),
  49. '@/types': resolve('src/types'),
  50. '@/components': resolve('src/components'),
  51. '@/env': resolve(`src/environment`),
  52. },
  53. weapp: {
  54. module: {
  55. postcss: {
  56. autoprefixer: {
  57. enable: true,
  58. config: {
  59. browsers: [
  60. 'last 3 versions',
  61. 'Android >= 4.1',
  62. 'ios >= 8'
  63. ]
  64. }
  65. },
  66. pxtransform: {
  67. enable: true,
  68. config: {
  69. }
  70. },
  71. url: {
  72. enable: true,
  73. config: {
  74. limit: 10240 // 设定转换尺寸上限
  75. }
  76. },
  77. cssModules: {
  78. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  79. config: {
  80. namingPattern: 'module', // 转换模式,取值为 global/module
  81. generateScopedName: '[name]__[local]___[hash:base64:5]'
  82. }
  83. }
  84. }
  85. }
  86. },
  87. h5: {
  88. publicPath: '/',
  89. staticDirectory: 'static',
  90. module: {
  91. postcss: {
  92. autoprefixer: {
  93. enable: true,
  94. config: {
  95. browsers: [
  96. 'last 3 versions',
  97. 'Android >= 4.1',
  98. 'ios >= 8'
  99. ]
  100. }
  101. },
  102. cssModules: {
  103. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  104. config: {
  105. namingPattern: 'module', // 转换模式,取值为 global/module
  106. generateScopedName: '[name]__[local]___[hash:base64:5]'
  107. }
  108. }
  109. }
  110. }
  111. }
  112. }
  113. module.exports = function (merge) {
  114. if (process.env.NODE_ENV === 'development') {
  115. return merge({}, config, require('./dev'))
  116. }
  117. return merge({}, config, require('./prod'))
  118. }