数字化园区前端项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. const path = require("path");
  2. const resolve = dir => path.join(__dirname, dir);
  3. const IS_PROD = ["production", "prod"].includes(process.env.NODE_ENV);
  4. const CompressionWebpackPlugin = require("compression-webpack-plugin");
  5. const productionGzipExtensions = /\.(js|css|json|txt|html|ico|svg)(\?.*)?$/i;
  6. module.exports = {
  7. publicPath: "/", // 默认'/',部署应用包时的基本 URL
  8. outputDir: "dist", // 'dist', 生产环境构建文件的目录
  9. assetsDir: "pc", // 相对于outputDir的静态资源(js、css、img、fonts)目录
  10. lintOnSave: false,
  11. indexPath: "pc.html",
  12. runtimeCompiler: true, // 是否使用包含运行时编译器的 Vue 构建版本
  13. productionSourceMap: false, // 生产环境的 source map
  14. devServer: {
  15. open: true,
  16. index: "index.html", //默认启动serve 打开index页面
  17. port: 8088,
  18. https: false,
  19. hotOnly: false,
  20. disableHostCheck: true,
  21. proxy: {
  22. "/domain": {
  23. // target: "http://192.168.18.138:80",
  24. target: "http://localhost:80",
  25. changeOrigin: true,
  26. pathRewrite: {
  27. "^/domain": "",
  28. },
  29. },
  30. },
  31. },
  32. chainWebpack: config => {
  33. // 修复热更新
  34. config.resolve.symlinks(true);
  35. // 添加别名
  36. config.resolve.alias
  37. .set("@", resolve("./src"))
  38. .set("@assets", resolve("./src/assets"))
  39. .set("@api", resolve("./src/api"))
  40. .set("@utils", resolve("./src/utils"))
  41. .set("@components", resolve("./src/components"))
  42. .set("@views", resolve("./src/views"));
  43. },
  44. configureWebpack: config => {
  45. config.optimization = {
  46. runtimeChunk: true,
  47. };
  48. const plugins = [];
  49. if (IS_PROD) {
  50. plugins.push(
  51. // 开启gzip
  52. new CompressionWebpackPlugin({
  53. filename: "[path].gz[query]",
  54. algorithm: "gzip",
  55. test: productionGzipExtensions,
  56. threshold: 10240,
  57. minRatio: 0.8,
  58. })
  59. );
  60. }
  61. config.plugins = [...config.plugins, ...plugins];
  62. },
  63. };