数字化园区前端项目
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.

vue.config.js 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. // 图形化打包详情
  7. // const BundleAnalyzer = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
  8. module.exports = {
  9. publicPath: "/", // 默认'/',部署应用包时的基本 URL
  10. outputDir: "dist", // 'dist', 生产环境构建文件的目录
  11. assetsDir: "pc", // 相对于outputDir的静态资源(js、css、img、fonts)目录
  12. lintOnSave: false,
  13. indexPath: "pc.html",
  14. runtimeCompiler: true, // 是否使用包含运行时编译器的 Vue 构建版本
  15. productionSourceMap: false, // 生产环境的 source map
  16. devServer: {
  17. open: true,
  18. index: "index.html", //默认启动serve 打开index页面
  19. port: 8089,
  20. https: false,
  21. hotOnly: false,
  22. disableHostCheck: true,
  23. proxy: {
  24. "/domain": {
  25. // target: "http://localhost:8089",
  26. // 测试环境
  27. // target: "http://192.168.18.236:18888/",
  28. // 临时测试环境
  29. target: "http://park.test.hhrchina.com/",
  30. // 谢老师
  31. // target: "http://192.168.18.138:18888/",
  32. // 阚老师
  33. // target: "http://192.168.18.121:18888/",
  34. // 何老师
  35. // target: "http://192.168.30.48:18888/",
  36. changeOrigin: true,
  37. pathRewrite: {
  38. "^/domain": "",
  39. },
  40. },
  41. },
  42. },
  43. chainWebpack: config => {
  44. // 修复热更新
  45. config.resolve.symlinks(true);
  46. // 添加别名
  47. config.resolve.alias
  48. .set("@", resolve("./src"))
  49. .set("@assets", resolve("./src/assets"))
  50. .set("@api", resolve("./src/api"))
  51. .set("@utils", resolve("./src/utils"))
  52. .set("@components", resolve("./src/components"))
  53. .set("@views", resolve("./src/views"))
  54. .set("@mixin", resolve("./src/mixin"));
  55. },
  56. css: {
  57. loaderOptions: {
  58. sass: {
  59. // 根据自己样式文件的位置调整
  60. prependData: `@import "@assets/scss/global.scss";`, //这里的@是别名
  61. },
  62. },
  63. },
  64. configureWebpack: config => {
  65. config.optimization = {
  66. runtimeChunk: true,
  67. };
  68. const plugins = [];
  69. if (IS_PROD) {
  70. plugins.push(
  71. // 开启gzip
  72. new CompressionWebpackPlugin({
  73. filename: "[path].gz[query]",
  74. algorithm: "gzip",
  75. test: productionGzipExtensions,
  76. threshold: 10240,
  77. minRatio: 0.8,
  78. })
  79. // new BundleAnalyzer()
  80. );
  81. }
  82. config.plugins = [...config.plugins, ...plugins];
  83. },
  84. };