index.js 2.7 KB

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