/* * @Author: shuishen 1109946754@qq.com * @Date: 2022-09-07 09:37:07 * @LastEditors: shuishen 1109946754@qq.com * @LastEditTime: 2025-01-20 16:18:45 * @FilePath: \srs-police-affairs\vue.config.js * @Description: * * Copyright (c) 2022 by shuishen 1109946754@qq.com, All Rights Reserved. */ const path = require("path") const CopywebpackPlugin = require("copy-webpack-plugin") const dvgisDist = "./node_modules/cesium" const webpack = require("webpack") const CompressionPlugin = require("compression-webpack-plugin") const pxtovw = require("postcss-px-to-viewport") const productionGzipExtensions = ["js", "css"] module.exports = { css: { loaderOptions: { // 给 sass-loader 传递选项 scss: { prependData: `@import "~@/styles/scssFile.scss";`, }, // postcss: { // plugins: [ //配置px转rem进行适配 // require('postcss-px2rem')({ // // 根标签字号大小根据设计稿宽度/flexible.js里的份数得到,这里假定设计稿宽度为3840 3840/24 = 160px // remUnit: 80 // }), // ] // } // postcss: { // //给postcss-loader传递选项 // plugins: [ // new pxtovw({ // unitToConvert: 'px', //需要转换的单位,默认为"px"; // viewportWidth: 1920, //设计稿的视口宽度 // viewportHeight: 1080, //设计稿的视口宽度 // unitPrecision: 5, //单位转换后保留的小数位数 // propList: ['*'], //要进行转换的属性列表,*表示匹配所有,!表示不转换 // viewportUnit: 'vw', //转换后的视口单位 // fontViewportUnit: 'vw', //转换后字体使用的视口单位 // selectorBlackList: [], //不进行转换的css选择器,继续使用原有单位 // minPixelValue: 1, //设置最小的转换数值 // mediaQuery: false, //设置媒体查询里的单位是否需要转换单位 // replace: true, //是否直接更换属性值,而不添加备用属性 // exclude: [/node_modules/], //忽略某些文件夹下的文件 // // landscape: true, // // landscapeUnit: 'vw', // // landscapeWidth: 1920 // }) // ] // } }, }, transpileDependencies: ['cesium'], // 其他配置 chainWebpack: (config) => { config.plugin("copy").use(CopywebpackPlugin, [ [ { from: path.join(dvgisDist, "Build/Cesium/Assets"), to: "libs/dc-sdk/resources/Assets", }, { from: path.join(dvgisDist, "Build/Cesium/ThirdParty"), to: "libs/dc-sdk/resources/ThirdParty", }, { from: path.join(dvgisDist, "Build/Cesium/Workers"), to: "libs/dc-sdk/resources/Workers", }, { from: "./public/img", to: "img", }, { from: "./public/model", to: "model", }, { from: "./public/video", to: "video", }, { from: "./public/libs", to: "libs", }, { from: "./public/depend", to: "depend", }, { from: "./public/static", to: "static", }, { from: "./public/images", to: "images", }, { from: "./public/qp", to: "qp", }, { from: "./public/tiles", to: "tiles", }, { from: "./public/warnings", to: "warnings", }, { from: "./public/3dtiles", to: "3dtiles", }, { from: "./public/hk", to: "hk", }, ], ]) // config.plugin("define").tap((args) => { // args[0]["process"] = { ...args[0]["process.env"] } // return args // }) }, configureWebpack: { externals: { vue: "Vue", Vuex: "Vuex", "vue-router": "VueRouter", "element-ui": "ELEMENT", echarts: "echarts", }, // webpack plugins plugins: [ // Ignore all locale files of moment.js new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), // 配置compression-webpack-plugin压缩 new CompressionPlugin({ algorithm: "gzip", test: new RegExp("\\.(" + productionGzipExtensions.join("|") + ")$"), threshold: 10240, minRatio: 0.8, }), new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 5, minChunkSize: 100, }), // 提供带 Content-Encoding 编码的压缩版的资源 // new CompressionPlugin({ // algorithm: 'gzip', // test: /\.js$|\.html$|\.css/, // 匹配文件名 // // test: /\.(js|css)$/, // threshold: 10240, // 对超过10k的数据压缩 // deleteOriginalAssets: false, // 不删除源文件 // minRatio: 0.8 // 压缩比 // }) ], }, devServer: { // open: false, // 编译完成是否打开网页 // host: "0.0.0.0", // 指定使用地址,默认localhost,0.0.0.0代表可以被外界访问 // // port: 82, // 访问端口 // https: false, // 编译失败时刷新页面 // hot: true, // 开启热加载 // hotOnly: false, // proxy: { // [process.env.VUE_APP_API]: {//拦截器(拦截链接中有/api) // target: process.env.VUE_API_DEV_TARGET,//'http://192.168.1.114:3000', //process.env.VUE_API_DEV_TARGET, //API服务器的地址 // changeOrigin: true, // pathRewrite: { // //'^/api': '/' // [`^${process.env.VUE_APP_API}`]: '', // //[`^${process.env.VUE_APP_API}`]: '/', //配置出来的接口没有 /api // } // } // } proxy: { "/api": { // target用于配置你允许访问数据的计算机名称,即是你的api接口的服务器地址 // target: "https://wrj.shuixiongit.com/srjwapi", // target: "http://z4042833u6.wicp.vip",//钟 // target: "https://238z61221a.oicp.vip",//原 target: "http://localhost:82", // target: "http://106.225.193.35:82", // target: "http://192.168.1.170:82", // target: "http://124.221.125.71:9529",//开发调试 // target: "http://172.16.13.150:82", // target: "http://47.217.32.232:80:8081/api", // ws: true, //启用webSocket6566 changeOrigin: true, //开启代理跨域 pathRewrite: { "^/api": "", }, }, }, }, }