vue.config.js 950 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. const path = require("path");
  2. const CompressionWebpackPlugin = require("compression-webpack-plugin");
  3. const isProd = process.env.NODE_ENV === "production";
  4. function resolve(dir) {
  5. return path.join(__dirname, dir);
  6. }
  7. module.exports = {
  8. publicPath: process.env.NODE_ENV === "production" ? "/" : "/",
  9. chainWebpack: (config) => {
  10. config.resolve.alias.set("@", resolve("src"));
  11. },
  12. configureWebpack: (config) => {
  13. /* gzip压缩,nginx需要开启gzip*/
  14. if (isProd) {
  15. // 配置webpack 压缩
  16. config.plugins.push(
  17. new CompressionWebpackPlugin({
  18. test: /\.js$|\.html$|\.css$/,
  19. // 超过4kb压缩
  20. threshold: 4096,
  21. })
  22. );
  23. }
  24. },
  25. devServer: {
  26. open: true,
  27. https: false,
  28. proxy: {
  29. "/api": {
  30. target: "http://18.163.50.191:19005/api",
  31. changeOrigin: true,
  32. pathRewrite: {
  33. "^/api": "",
  34. },
  35. },
  36. },
  37. },
  38. };