wepy.config.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. const path = require('path')
  2. const prod = process.env.NODE_ENV === 'production'
  3. module.exports = {
  4. wpyExt: '.wpy',
  5. build: {
  6. web: {
  7. htmlTemplate: path.join('src', 'index.template.html'),
  8. htmlOutput: path.join('web', 'index.html'),
  9. jsOutput: path.join('web', 'index.js')
  10. }
  11. },
  12. resolve: {
  13. alias: {
  14. 'ald': path.join(__dirname, 'src/utils/ald-stat'),
  15. 'lib': path.join(__dirname, 'src/lib/lib'),
  16. 'client': path.join(__dirname, 'src/api/client'),
  17. 'md5': path.join(__dirname, 'src/lib/md5'),
  18. '@': path.join(__dirname, 'src')
  19. },
  20. modules: ['node_modules']
  21. },
  22. // eslint: true,
  23. compilers: {
  24. // less: {
  25. // compress: true
  26. // },
  27. sass: {
  28. outputStyle: 'compressed'
  29. },
  30. babel: {
  31. sourceMap: false,
  32. presets: [
  33. 'env'
  34. ],
  35. plugins: [
  36. 'transform-class-properties',
  37. 'transform-decorators-legacy',
  38. 'transform-object-rest-spread',
  39. 'transform-export-extensions'
  40. ]
  41. }
  42. },
  43. plugins: {
  44. imgbase64: {
  45. css: false,
  46. html: true,
  47. output: 'dist',
  48. // fileType: 'scss',
  49. path: '/src/img'
  50. },
  51. replace: {
  52. filter: /lib\.js$/,
  53. config: {
  54. find: /__ENV__/g,
  55. replace: process.env.NODE_ENV
  56. }
  57. }
  58. },
  59. appConfig: {
  60. noPromiseAPI: ['createSelectorQuery']
  61. }
  62. }
  63. if (prod) {
  64. delete module.exports.compilers.babel.sourcesMap
  65. // 压缩sass
  66. module.exports.compilers['sass'] = {
  67. outputStyle: 'compressed'
  68. }
  69. // 压缩less
  70. // module.exports.compilers['less'] = {
  71. // compress: true
  72. // }
  73. // 压缩js
  74. module.exports.plugins = {
  75. uglifyjs: {
  76. filter: /\.js$/,
  77. config: {}
  78. },
  79. imagemin: {
  80. filter: /\.(jpg|png|jpeg)$/,
  81. config: {
  82. jpg: {
  83. quality: 80
  84. },
  85. png: {
  86. quality: 80
  87. }
  88. }
  89. },
  90. imgbase64: {
  91. css: false,
  92. html: false,
  93. output: 'dist',
  94. fileType: 'scss',
  95. path: '/src/img'
  96. },
  97. replace: {
  98. filter: /lib\.js$/,
  99. config: {
  100. find: /__ENV__/g,
  101. replace: process.env.NODE_ENV
  102. }
  103. }
  104. }
  105. }