vue.config.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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: "http://192.168.5.4:16200", // 石月
  62. target: "http://192.168.50.235:16200", //内网
  63. // target: "http://192.168.5.15:16200",
  64. // target: "http://106.120.102.238:16600", //外网
  65. // target: "http://10.96.137.5",
  66. changeOrigin: true,
  67. pathRewrite: {
  68. "^/api": "", // 需要regit write重写的,
  69. },
  70. onProxyReq(proxyReq, req, res) {
  71. console.log("Proxying request to:", proxyReq.path); // 打印代理请求路径
  72. },
  73. },
  74. "/transDataWeb": {
  75. target: "http://192.168.50.241:9000/trans_data_web",
  76. changeOrigin: true,
  77. pathRewrite: {
  78. "^/transDataWeb": "", // 需要regit write重写的,
  79. },
  80. },
  81. "/sAlgorithm": {
  82. target: "http://192.168.5.28:8666", // 目标地址
  83. changeOrigin: true,
  84. pathRewrite: {
  85. "^/sAlgorithm": "", // 如果后端需要 `/api` 前缀
  86. },
  87. onProxyReq(proxyReq, req, res) {
  88. console.log("Proxying request to:", proxyReq.path); // 打印代理请求路径
  89. },
  90. },
  91. "/databaseApi": {
  92. target: "http://192.168.5.18:3000",
  93. changeOrigin: true,
  94. pathRewrite: {
  95. "^/databaseApi": "", // 如果后端需要 `/api` 前缀
  96. },
  97. },
  98. },
  99. },
  100. configureWebpack: {
  101. resolve: {
  102. alias: {
  103. "@": resolve("src"),
  104. },
  105. },
  106. optimization: {
  107. usedExports: true,
  108. splitChunks: {
  109. chunks: "all",
  110. },
  111. minimize: true,
  112. minimizer: [new TerserPlugin(), new CssMinimizerPlugin()],
  113. },
  114. // plugins: [
  115. // new HtmlWebpackPlugin({
  116. // filename: "custom-filename.html", // 自定义输出的 HTML 文件名
  117. // title: "风机运行管理系统", // 设置页面的标题
  118. // // 其他配置...
  119. // }),
  120. // // 其他插件...
  121. // ],
  122. },
  123. pluginOptions: {
  124. "style-resources-loader": {
  125. preProcessor: "sass",
  126. patterns: [],
  127. },
  128. },
  129. configureWebpack: {
  130. devtool: "source-map",
  131. },
  132. };