wepy.config.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. const path = require('path');
  2. var prod = process.env.NODE_ENV === 'production';
  3. module.exports = {
  4. wpyExt: '.wpy',
  5. eslint: false,
  6. cliLogs: !prod,
  7. build: {
  8. },
  9. resolve: {
  10. alias: {
  11. counter: path.join(__dirname, 'src/components/counter'),
  12. '@': path.join(__dirname, 'src')
  13. },
  14. aliasFields: ['wepy', 'weapp'],
  15. modules: ['node_modules']
  16. },
  17. compilers: {
  18. sass: {
  19. compress: prod
  20. },
  21. /*sass: {
  22. outputStyle: 'compressed'
  23. },*/
  24. babel: {
  25. sourceMap: true,
  26. presets: [
  27. 'env'
  28. ],
  29. plugins: [
  30. 'transform-class-properties',
  31. 'transform-decorators-legacy',
  32. 'transform-object-rest-spread',
  33. 'transform-export-extensions',
  34. ]
  35. }
  36. },
  37. plugins: {
  38. // 'img2base64': {
  39. // css: true,
  40. // html: true,
  41. // // path: './app/assets/images'
  42. // }
  43. },
  44. appConfig: {
  45. noPromiseAPI: ['createSelectorQuery']
  46. }
  47. }
  48. if (prod) {
  49. // 压缩sass
  50. // module.exports.compilers['sass'] = {outputStyle: 'compressed'}
  51. // 压缩js
  52. module.exports.plugins = {
  53. uglifyjs: {
  54. filter: /\.js$/,
  55. config: {
  56. }
  57. },
  58. imagemin: {
  59. filter: /\.(jpg|png|jpeg)$/,
  60. config: {
  61. jpg: {
  62. quality: 80
  63. },
  64. png: {
  65. quality: 80
  66. }
  67. }
  68. }
  69. }
  70. }