wepy.config.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. const path = require('path')
  2. var prod = process.env.NODE_ENV === 'production'
  3. module.exports = {
  4. wpyExt: '.wpy',
  5. eslint: true,
  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: [
  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. },
  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. }