vue.config.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. // 页面 IP/端口:在各 .env.* 中配置 VUE_APP_DEV_HOST、VUE_APP_DEV_PORT
  60. host: process.env.VUE_APP_DEV_HOST || "localhost",
  61. port: process.env.VUE_APP_DEV_PORT
  62. ? Number(process.env.VUE_APP_DEV_PORT)
  63. : 8080,
  64. proxy: {
  65. "/api": {
  66. target: process.env.VUE_APP_APIPROXY,
  67. // target: "http://192.168.5.4:16200", // 石月
  68. // target: "http://192.168.5.15:16200",//陈
  69. changeOrigin: true,
  70. pathRewrite: {
  71. "^/api": "", // 去掉 /api 前缀
  72. },
  73. },
  74. "/DatangEnosData": {
  75. target: process.env.VUE_APP_DatangEnosData_APIPROXY,
  76. changeOrigin: true,
  77. pathRewrite: {
  78. "^/DatangEnosData": "",
  79. },
  80. },
  81. // 健康分析接口(勿用 /health,避免与路由 /home/health 及 history 回退冲突)
  82. "/healthApi": {
  83. target: process.env.VUE_APP_HEALTH_APIPROXY,
  84. changeOrigin: true,
  85. pathRewrite: {
  86. "^/healthApi": "",
  87. },
  88. },
  89. // 未知量 //振动、激光测距仪
  90. "/WZLapi": {
  91. target: process.env.VUE_APP_WZLAPIPROXY,
  92. changeOrigin: true,
  93. pathRewrite: {
  94. "^/WZLapi": "", // 去掉 /WZLapi 前缀
  95. },
  96. },
  97. "/ETLapi": {
  98. target: process.env.VUE_APP_ETLAPIPROXY,
  99. changeOrigin: true,
  100. pathRewrite: {
  101. "^/ETLapi": "", // 去掉 /WZLapi 前缀
  102. },
  103. onProxyReq(proxyReq, req, res) {
  104. console.log("Proxying /sAlgorithm request to:", proxyReq.path); // 打印代理请求路径
  105. },
  106. },
  107. "/tiles": {
  108. target: process.env.VUE_APP_MAP, // 或者外网地址
  109. changeOrigin: true,
  110. pathRewrite: {
  111. "^/tiles": "/tiles",
  112. },
  113. },
  114. // 王娇娇健康评估
  115. "/AnalysisMulti": {
  116. target: process.env.VUE_APP_AnalysisMultiAPIPROXY,
  117. changeOrigin: true,
  118. pathRewrite: {
  119. "^/AnalysisMulti": "",
  120. },
  121. },
  122. // 数据转换亮亮
  123. "/transDataWeb": {
  124. target: process.env.VUE_APP_WZLAPIPROXY,
  125. changeOrigin: true,
  126. pathRewrite: {
  127. "^/transDataWeb": "",
  128. },
  129. },
  130. //自定义算法文佳
  131. "/sAlgorithm": {
  132. target: process.env.VUE_APP_sAlgorithmAPIPROXY,
  133. changeOrigin: true,
  134. pathRewrite: {
  135. "^/sAlgorithm": "",
  136. },
  137. },
  138. //nodejs 数据库数据
  139. "/databaseApi": {
  140. target: process.env.VUE_APP_databaseApiAPIPROXY,
  141. // target: "http://106.120.102.238:58880", //这个代理会走两次代理转发
  142. changeOrigin: true,
  143. pathRewrite: {
  144. "^/databaseApi": "",
  145. },
  146. },
  147. //nodejs 数据库数据
  148. "/downLoadChart": {
  149. target: process.env.VUE_APP_downLoadChartAPIPROXY,
  150. // target: "http://0.0.0.0:3001",
  151. // target: "http://192.168.50.235:8999/downLoadChart", //内网演示
  152. // target: "http://192.168.50.235:8999/downLoadChart", //内网演示 这个是对
  153. // target: "http://106.120.102.238:28999/downLoadChart", //外网演示
  154. changeOrigin: true,
  155. pathRewrite: {
  156. "^/downLoadChart": "",
  157. },
  158. },
  159. },
  160. },
  161. configureWebpack: {
  162. resolve: {
  163. alias: {
  164. "@": resolve("src"),
  165. },
  166. },
  167. optimization: {
  168. usedExports: true,
  169. splitChunks: {
  170. chunks: "all",
  171. },
  172. minimize: true,
  173. minimizer: [new TerserPlugin(), new CssMinimizerPlugin()],
  174. },
  175. // plugins: [
  176. // new HtmlWebpackPlugin({
  177. // filename: "custom-filename.html", // 自定义输出的 HTML 文件名
  178. // title: "风机运行管理系统", // 设置页面的标题
  179. // // 其他配置...
  180. // }),
  181. // // 其他插件...
  182. // ],
  183. },
  184. pluginOptions: {
  185. "style-resources-loader": {
  186. preProcessor: "sass",
  187. patterns: [],
  188. },
  189. },
  190. configureWebpack: {
  191. devtool: "source-map",
  192. },
  193. };