index.js 2.6 KB

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