wepy.config.js 2.3 KB

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