vue.config.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. const { defineConfig } = require("@vue/cli-service");
  2. const Package = require("./package");
  3. const CompressionPlugin = require("compression-webpack-plugin");
  4. const { isEnvProduction, isEnvInterfaceJoinDebug } = require("@vci/vci/other/ijd");
  5. const path = require("node:path");
  6. module.exports = defineConfig({
  7. assetsDir: "assets",
  8. publicPath: "./",
  9. outputDir: Package.name + (isEnvInterfaceJoinDebug ? "-ijd" : ""),
  10. productionSourceMap: false,
  11. transpileDependencies: true,
  12. devServer: {
  13. port: 8888,
  14. host: "localhost"
  15. },
  16. chainWebpack: config => {
  17. config.resolve.alias
  18. .set("~", path.resolve(__dirname, "src"))
  19. ;
  20. config.module
  21. .rule("cursor")
  22. .test(/\.cur$/)
  23. .use("cursor")
  24. .loader("file-loader")
  25. .options({
  26. name: "assets/cur/[name].[hash:8].[ext]"
  27. });
  28. config
  29. .plugin("html")
  30. .tap(args => {
  31. args[0]["title-cn"] = Package["name-cn"];
  32. return args;
  33. });
  34. isEnvProduction && config.plugin("compress-gzip")
  35. .use(CompressionPlugin)
  36. .tap(args => {
  37. args[0] = {
  38. algorithm: "gzip",
  39. test: /\.(js|css|json|txt|html|ico|svg)(\?.*)?$/i,
  40. threshold: 2048,
  41. minRatio: 0.8
  42. };
  43. return args;
  44. });
  45. }
  46. });