const path = require("path"); const TerserPlugin = require("terser-webpack-plugin"); const CssMinimizerPlugin = require("css-minimizer-webpack-plugin"); const WorkboxPlugin = require("workbox-webpack-plugin"); const HappyPack = require("happypack"); const webpack = require("webpack"); // const HtmlWebpackPlugin = require("html-webpack-plugin"); function resolve(dir) { return path.join(__dirname, dir); } module.exports = { chainWebpack(config) { config.module.rule("svg").exclude.add(resolve("src/icons")).end(); config.module .rule("icons") .test(/\.svg$/) .include.add(resolve("src/icons")) .end() .use("svg-sprite-loader") .loader("svg-sprite-loader") .options({ symbolId: "icon-[name]", }) .end(); config.plugin("happypack").use(HappyPack, [ { loaders: ["babel-loader"], }, ]); // config.plugin('dll').use(webpack.DllPlugin, [ // { // name: '[name]_library', // path: path.join(__dirname, 'dll', '[name]-manifest.json'), // }, // ]); config.plugin("workbox").use(WorkboxPlugin.GenerateSW, [ { clientsClaim: true, skipWaiting: true, }, ]); }, css: { loaderOptions: { postcss: { postcssOptions: { plugins: [require("tailwindcss"), require("autoprefixer")], }, }, sass: { additionalData: ` @import "@/styles/global.scss"; `, }, }, }, devServer: { // contentBase: path.join(__dirname, "public"), proxy: { "/api": { // target: "http://192.168.5.4:16200", // 石月 // target: "http://192.168.50.235:16200", // 内网 // target: "http://192.168.5.15:16200", // target: "http://192.168.50.235:16500", //演示环境 target: "http://106.120.102.238:26500", //外网演示环境 // target: "http://106.120.102.238:16700", // 外网16700 生产16600 // target: "http://10.96.137.5", changeOrigin: true, pathRewrite: { "^/api": "", // 去掉 /api 前缀 }, }, // 未知量 //振动、激光测距仪 "/WZLapi": { // target: "http://192.168.50.241:9001", // WZLapi 目标地址 target: "http://106.120.102.238:18080/WindTransDev", // WZLapi 外网目标地址 changeOrigin: true, pathRewrite: { "^/WZLapi": "", // 去掉 /WZLapi 前缀 }, }, "/ETLapi": { // target: "http://192.168.50.241:9001", // WZLapi 目标地址 // target: "http://192.168.5.11:8001", // WZLapi 目标地址 // target: "http://106.120.102.238:18080/ImportDataDev", //导数工具 // target: "http://106.120.102.238:18080/WindTransDev", //WTL外网目标地址 target: "http://106.120.102.238:28999/transDataWeb", //WTL演示环境 // target: "http://192.168.50.235:8999/transDataWeb", //WTL演示环境 changeOrigin: true, pathRewrite: { "^/ETLapi": "", // 去掉 /WZLapi 前缀 }, onProxyReq(proxyReq, req, res) { console.log("Proxying /sAlgorithm request to:", proxyReq.path); // 打印代理请求路径 }, }, // 文佳 "/WJapi": { // target: "http://192.168.50.235:8888", // WZLapi 内网 目标地址 target: "http://106.120.102.238:18888", // WZLapi/ 内网 目标地址 changeOrigin: true, pathRewrite: { "^/WJapi": "", // 去掉 /WZLapi 前缀 }, onProxyReq(proxyReq, req, res) { console.log("Proxying /sAlgorithm request to:", proxyReq.path); // 打印代理请求路径 }, }, // 数据转换亮亮 "/transDataWeb": { // target: "http://192.168.50.241:9000/trans_data_web",//生产 target: "http://192.168.50.235/transDataWeb", //测试 // target: "http://192.168.50.235:8999/transDataWeb", //测试 changeOrigin: true, pathRewrite: { "^/transDataWeb": "", // 去掉 /transDataWeb 前缀 }, }, //自定义算法文佳 "/sAlgorithm": { // target: "http://192.168.50.235:8666", // 目标地址 target: "http://106.120.102.238:58880",//这个代理会走两次代理转发 changeOrigin: true, pathRewrite: { "^/sAlgorithm": "", // 如果后端需要 `/api` 前缀 }, }, //nodejs 数据库数据 "/databaseApi": { target: "http://192.168.50.234:3000", // target: "http://106.120.102.238:58880",//这个代理会走两次代理转发 changeOrigin: true, pathRewrite: { "^/databaseApi": "", // 去掉 /databaseApi 前缀 }, }, //nodejs 数据库数据 "/downLoadChart": { target: "http://127.0.0.1:3000", // target: "http://106.120.102.238:58880", changeOrigin: true, pathRewrite: { "^/downLoadChart": "", // 去掉 /downLoadChart 前缀 }, }, }, }, configureWebpack: { resolve: { alias: { "@": resolve("src"), }, }, optimization: { usedExports: true, splitChunks: { chunks: "all", }, minimize: true, minimizer: [new TerserPlugin(), new CssMinimizerPlugin()], }, // plugins: [ // new HtmlWebpackPlugin({ // filename: "custom-filename.html", // 自定义输出的 HTML 文件名 // title: "风机运行管理系统", // 设置页面的标题 // // 其他配置... // }), // // 其他插件... // ], }, pluginOptions: { "style-resources-loader": { preProcessor: "sass", patterns: [], }, }, configureWebpack: { devtool: "source-map", }, };