vue.config.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. const path = require("path");
  2. const TerserPlugin = require("terser-webpack-plugin");
  3. const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
  4. const WorkboxPlugin = require("workbox-webpack-plugin");
  5. const HappyPack = require("happypack");
  6. const webpack = require("webpack");
  7. // const HtmlWebpackPlugin = require("html-webpack-plugin");
  8. function resolve(dir) {
  9. return path.join(__dirname, dir);
  10. }
  11. module.exports = {
  12. chainWebpack(config) {
  13. config.module.rule("svg").exclude.add(resolve("src/icons")).end();
  14. config.module
  15. .rule("icons")
  16. .test(/\.svg$/)
  17. .include.add(resolve("src/icons"))
  18. .end()
  19. .use("svg-sprite-loader")
  20. .loader("svg-sprite-loader")
  21. .options({
  22. symbolId: "icon-[name]",
  23. })
  24. .end();
  25. config.plugin("happypack").use(HappyPack, [
  26. {
  27. loaders: ["babel-loader"],
  28. },
  29. ]);
  30. // config.plugin('dll').use(webpack.DllPlugin, [
  31. // {
  32. // name: '[name]_library',
  33. // path: path.join(__dirname, 'dll', '[name]-manifest.json'),
  34. // },
  35. // ]);
  36. config.plugin("workbox").use(WorkboxPlugin.GenerateSW, [
  37. {
  38. clientsClaim: true,
  39. skipWaiting: true,
  40. },
  41. ]);
  42. },
  43. css: {
  44. loaderOptions: {
  45. postcss: {
  46. postcssOptions: {
  47. plugins: [require("tailwindcss"), require("autoprefixer")],
  48. },
  49. },
  50. sass: {
  51. additionalData: `
  52. @import "@/styles/global.scss";
  53. `,
  54. },
  55. },
  56. },
  57. devServer: {
  58. // contentBase: path.join(__dirname, "public"),
  59. proxy: {
  60. "/api": {
  61. target: process.env.VUE_APP_APIPROXY,
  62. // target: "http://192.168.5.4:16200", // 石月
  63. // target: "http://192.168.5.15:16200",//陈
  64. changeOrigin: true,
  65. pathRewrite: {
  66. "^/api": "", // 去掉 /api 前缀
  67. },
  68. },
  69. // 未知量 //振动、激光测距仪
  70. "/WZLapi": {
  71. target: process.env.VUE_APP_WZLAPIPROXY,
  72. changeOrigin: true,
  73. pathRewrite: {
  74. "^/WZLapi": "", // 去掉 /WZLapi 前缀
  75. },
  76. },
  77. "/ETLapi": {
  78. target: process.env.VUE_APP_ETLAPIPROXY,
  79. changeOrigin: true,
  80. pathRewrite: {
  81. "^/ETLapi": "", // 去掉 /WZLapi 前缀
  82. },
  83. onProxyReq(proxyReq, req, res) {
  84. console.log("Proxying /sAlgorithm request to:", proxyReq.path); // 打印代理请求路径
  85. },
  86. },
  87. "/tiles": {
  88. target: process.env.VUE_APP_MAP, // 或者外网地址
  89. changeOrigin: true,
  90. pathRewrite: {
  91. "^/tiles": "/tiles",
  92. },
  93. },
  94. // 王娇娇健康评估
  95. "/AnalysisMulti": {
  96. target: process.env.VUE_APP_AnalysisMultiAPIPROXY,
  97. changeOrigin: true,
  98. pathRewrite: {
  99. "^/AnalysisMulti": "",
  100. },
  101. },
  102. // 数据转换亮亮
  103. "/transDataWeb": {
  104. target: process.env.VUE_APP_WZLAPIPROXY,
  105. changeOrigin: true,
  106. pathRewrite: {
  107. "^/transDataWeb": "",
  108. },
  109. },
  110. //自定义算法文佳
  111. "/sAlgorithm": {
  112. target: process.env.VUE_APP_sAlgorithmAPIPROXY,
  113. changeOrigin: true,
  114. pathRewrite: {
  115. "^/sAlgorithm": "",
  116. },
  117. },
  118. //nodejs 数据库数据
  119. "/databaseApi": {
  120. target: process.env.VUE_APP_databaseApiAPIPROXY,
  121. // target: "http://106.120.102.238:58880", //这个代理会走两次代理转发
  122. changeOrigin: true,
  123. pathRewrite: {
  124. "^/databaseApi": "",
  125. },
  126. },
  127. //nodejs 数据库数据
  128. "/downLoadChart": {
  129. target: process.env.VUE_APP_downLoadChartAPIPROXY,
  130. // target: "http://0.0.0.0:3001",
  131. // target: "http://192.168.50.235:8999/downLoadChart", //内网演示
  132. // target: "http://106.120.102.238:28999/downLoadChart", //外网演示
  133. changeOrigin: true,
  134. pathRewrite: {
  135. "^/downLoadChart": "",
  136. },
  137. },
  138. },
  139. },
  140. configureWebpack: {
  141. resolve: {
  142. alias: {
  143. "@": resolve("src"),
  144. },
  145. },
  146. optimization: {
  147. usedExports: true,
  148. splitChunks: {
  149. chunks: "all",
  150. },
  151. minimize: true,
  152. minimizer: [new TerserPlugin(), new CssMinimizerPlugin()],
  153. },
  154. // plugins: [
  155. // new HtmlWebpackPlugin({
  156. // filename: "custom-filename.html", // 自定义输出的 HTML 文件名
  157. // title: "风机运行管理系统", // 设置页面的标题
  158. // // 其他配置...
  159. // }),
  160. // // 其他插件...
  161. // ],
  162. },
  163. pluginOptions: {
  164. "style-resources-loader": {
  165. preProcessor: "sass",
  166. patterns: [],
  167. },
  168. },
  169. configureWebpack: {
  170. devtool: "source-map",
  171. },
  172. };