vue.config.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. const path = require('path')
  2. const fs = require('fs')
  3. //const TerserPlugin = require('terser-webpack-plugin')
  4. /**
  5. * 拼接相对于当前目录的下 文件的相对路径
  6. * @param dir 目录
  7. * @return {string}
  8. */
  9. function resolove(dir) {
  10. return path.join(__dirname, dir)
  11. }
  12. module.exports = {
  13. lintOnSave: true,
  14. productionSourceMap: false,
  15. css: {
  16. },
  17. devServer: {
  18. proxy: {
  19. '/api': {
  20. // 本地服务接口地址
  21. target: 'http://127.0.0.1:8443/',
  22. ws: true,
  23. pathRewrite: {
  24. '^/api': '/',
  25. },
  26. },
  27. },
  28. },
  29. chainWebpack: config => {
  30. // 移除 prefetch 插件
  31. config.plugins.delete('prefetch');
  32. config.resolve.alias
  33. .set('IMG', resolove('static/image'))
  34. .set('PAGES', resolove('pages'))
  35. .set('COMPONENTS', resolove('components'))
  36. .set('UTIL', resolove('utils'))
  37. .set('API', resolove('api'));
  38. },
  39. configureWebpack: {
  40. plugins: [],
  41. optimization: {
  42. minimizer: [
  43. /** new TerserPlugin({
  44. terserOptions: {
  45. warnings: false,
  46. compress: {
  47. drop_console: true,
  48. drop_debugger: true,
  49. pure_funcs: ['console.log']
  50. }
  51. }
  52. })*/
  53. ]
  54. }
  55. }
  56. };