wepy.config.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. // web: {
  9. // htmlTemplate: path.join('src', 'index.template.html'),
  10. // htmlOutput: path.join('web', 'index.html'),
  11. // jsOutput: path.join('web', 'index.js')
  12. // }
  13. },
  14. resolve: {
  15. alias: {
  16. counter: path.join(__dirname, 'src/components/counter'),
  17. '@': path.join(__dirname, 'src')
  18. },
  19. aliasFields: ['wepy', 'weapp'],
  20. modules: ['node_modules']
  21. },
  22. compilers: {
  23. less: {
  24. compress: prod
  25. },
  26. /*sass: {
  27. outputStyle: 'compressed'
  28. },*/
  29. babel: {
  30. sourceMap: true,
  31. presets: ['env'],
  32. plugins: [
  33. 'transform-class-properties',
  34. 'transform-decorators-legacy',
  35. 'transform-object-rest-spread',
  36. 'transform-export-extensions'
  37. ]
  38. }
  39. },
  40. plugins: {},
  41. appConfig: {
  42. noPromiseAPI: ['createSelectorQuery']
  43. }
  44. };
  45. if (prod) {
  46. // 压缩sass
  47. // module.exports.compilers['sass'] = {outputStyle: 'compressed'}
  48. // 压缩js
  49. module.exports.plugins = {
  50. uglifyjs: {
  51. filter: /\.js$/,
  52. config: {}
  53. },
  54. imagemin: {
  55. filter: /\.(jpg|png|jpeg)$/,
  56. config: {
  57. jpg: {
  58. quality: 80
  59. },
  60. png: {
  61. quality: 80
  62. }
  63. }
  64. }
  65. };
  66. }