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. '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. "syntax-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: true,
  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. }