wepy.config.js 2.4 KB

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