wepy.config.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. const path = require('path')
  2. var 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. '@': path.join(__dirname, 'src')
  17. },
  18. modules: ['node_modules']
  19. },
  20. // eslint: true,
  21. compilers: {
  22. // less: {
  23. // compress: true
  24. // },
  25. sass: {
  26. outputStyle: 'compressed'
  27. },
  28. babel: {
  29. sourceMap: false,
  30. presets: [
  31. 'env'
  32. ],
  33. plugins: [
  34. 'transform-class-properties',
  35. 'transform-decorators-legacy',
  36. 'transform-object-rest-spread',
  37. 'transform-export-extensions'
  38. ]
  39. }
  40. },
  41. plugins: {
  42. imgbase64: {
  43. css: false,
  44. html: true,
  45. output: 'dist',
  46. // fileType: 'scss',
  47. path: '/src/img'
  48. }
  49. },
  50. appConfig: {
  51. noPromiseAPI: ['createSelectorQuery']
  52. }
  53. }
  54. if (prod) {
  55. delete module.exports.compilers.babel.sourcesMap
  56. // 压缩sass
  57. module.exports.compilers['sass'] = {
  58. outputStyle: 'compressed'
  59. }
  60. // 压缩less
  61. // module.exports.compilers['less'] = {
  62. // compress: true
  63. // }
  64. // 压缩js
  65. module.exports.plugins = {
  66. uglifyjs: {
  67. filter: /\.js$/,
  68. config: {}
  69. },
  70. imagemin: {
  71. filter: /\.(jpg|png|jpeg)$/,
  72. config: {
  73. jpg: {
  74. quality: 80
  75. },
  76. png: {
  77. quality: 80
  78. }
  79. }
  80. },
  81. imgbase64: {
  82. css: false,
  83. html: true,
  84. output: 'dist',
  85. // fileType: 'scss',
  86. path: '/src/img'
  87. }
  88. }
  89. }