This commit is contained in:
‘937886381’
2025-12-09 16:55:39 +08:00
parent a907c7273e
commit 2d200dd1a6
24 changed files with 201 additions and 210 deletions

View File

@@ -25,4 +25,4 @@ VUE_APP_CAPTCHA_ENABLE = true
VUE_APP_DOC_ENABLE = true
# 百度统计
VUE_APP_BAIDU_CODE = fadc1bd5db1a1d6f581df60a1807f8ab
# VUE_APP_BAIDU_CODE = fadc1bd5db1a1d6f581df60a1807f8ab

View File

@@ -1,18 +1,20 @@
# 生产环境配置
NODE_ENV = 'production'
ENV = 'production'
# 页面标题
VUE_APP_TITLE = 洛玻集团驾驶舱
# 芋道管理系统/生产环境
# 建议使用相对路径或通过nginx配置的域名/路径避免写死IP和端口
VUE_APP_BASE_API = '' # 示例使用相对路径由nginx转发到实际后端地址
# VUE_APP_BASE_API = '/prod-api'
VUE_APP_BASE_API = ''
# 根据服务器或域名修改使用相对路径避免写死IP和端口
PUBLIC_PATH = '' # 改为根路径,或根据实际二级部署路径设置(如 '/subpath/'
# 根据服务器或域名修改
# PUBLIC_PATH = 'http://my-pi.com:8888/yudao-admin/'
# PUBLIC_PATH = 'http://192.168.0.33:8888/'
PUBLIC_PATH = ''
# 二级部署路径(如果需要)
# VUE_APP_APP_NAME ='yudao-admin'
# 二级部署路径
VUE_APP_APP_NAME ='yudao-admin'
# 多租户的开关
VUE_APP_TENANT_ENABLE = true

BIN
dist.zip

Binary file not shown.

View File

@@ -68,3 +68,11 @@ export function getOperateCockpit(data) {
});
}
export function getOrderDetail(data) {
return request({
url: "/lb/operate-cockpit/getOrderDetail",
method: "post",
data: data,
});
}

View File

@@ -155,9 +155,9 @@ export default {
methods: {
getData(obj) {
getProductSaleAnalysis({
startTime: 1762704000000,
endTime: 1762790400000,
mode: 1
startTime: obj.startTime,
endTime: obj.endTime,
mode: obj.mode,
}).then((res) => {
console.log(res);
this.productSaleData = [

View File

@@ -98,44 +98,40 @@ export default {
const mode = this.activeTime + 1; // 1=日2=月3=年
const defaultMoment = moment(); // 默认当前时间
// 处理选择的日期转为moment对象兼容不同选择器格式
console.log('this.date', this.date);
const targetMoment = this.date
? moment(this.date, this.getPickerType === 'date' ? 'YYYY-MM-DD' : (this.getPickerType === 'month' ? 'YYYY-MM' : 'YYYY'))
: defaultMoment;
// 验证日期有效性
if (!targetMoment.isValid()) {
console.error('无效日期:', this.date);
return { startTime, endTime, mode };
}
// 1. 日维度:当天0点 → 次日0点
// 1. 日维度:00:00:00 → 23:59:59无毫秒
if (this.activeTime === 0) {
startTime = targetMoment.startOf('day').valueOf(); // 当天00:00:00 时间戳
endTime = targetMoment.add(1, 'day').startOf('day').valueOf(); // 次日00:00:00 时间戳
startTime = targetMoment.startOf('day').millisecond(0).valueOf();
endTime = targetMoment.endOf('day').millisecond(0).valueOf();
}
// 2. 月维度当月1日0点 → 次月1日0点
// 2. 月维度当月1日00:00:00 → 当月最后一天23:59:59无毫秒
else if (this.activeTime === 1) {
startTime = targetMoment.startOf('month').valueOf(); // 当月1日00:00:00 时间戳
endTime = targetMoment.add(1, 'month').startOf('month').valueOf(); // 次月1日00:00:00 时间戳
startTime = targetMoment.startOf('month').millisecond(0).valueOf();
endTime = targetMoment.endOf('month').millisecond(0).valueOf();
}
// 3. 年维度当年1月1日0点 → 次年1月1日0点
// 3. 年维度当年1月1日00:00:00 → 当年最后一天23:59:59无毫秒
else if (this.activeTime === 2) {
startTime = targetMoment.startOf('year').valueOf(); // 当年1月1日00:00:00 时间戳
endTime = targetMoment.add(1, 'year').startOf('year').valueOf(); // 次年1月1日00:00:00 时间戳
startTime = targetMoment.startOf('year').millisecond(0).valueOf();
endTime = targetMoment.endOf('year').millisecond(0).valueOf();
}
// 调试输出(格式化显示,便于验证)
// 调试输出:验证是否去掉毫秒
console.log('时间范围计算结果:', {
mode,
startTime: moment(startTime).format('YYYY-MM-DD HH:mm:ss'),
endTime: moment(endTime).format('YYYY-MM-DD HH:mm:ss'),
startTimeStamp: startTime,
endTimeStamp: endTime
startTime: moment(startTime * 1000).format('YYYY-MM-DD HH:mm:ss'), // 格式2025-11-30 00:00:00
endTime: moment(endTime * 1000).format('YYYY-MM-DD HH:mm:ss'), // 格式2025-11-30 23:59:59无毫秒
startTimeStamp: startTime, // 秒级时间戳1764422400
endTimeStamp: endTime // 秒级时间戳1764508799
});
return { startTime, endTime, mode };

View File

@@ -103,44 +103,40 @@ export default {
const mode = this.activeTime + 1; // 1=日2=月3=年
const defaultMoment = moment(); // 默认当前时间
// 处理选择的日期转为moment对象兼容不同选择器格式
console.log('this.date', this.date);
const targetMoment = this.date
? moment(this.date, this.getPickerType === 'date' ? 'YYYY-MM-DD' : (this.getPickerType === 'month' ? 'YYYY-MM' : 'YYYY'))
: defaultMoment;
// 验证日期有效性
if (!targetMoment.isValid()) {
console.error('无效日期:', this.date);
return { startTime, endTime, mode };
}
// 1. 日维度:当天0点 → 次日0点
// 1. 日维度:00:00:00 → 23:59:59无毫秒
if (this.activeTime === 0) {
startTime = targetMoment.startOf('day').valueOf(); // 当天00:00:00 时间戳
endTime = targetMoment.add(1, 'day').startOf('day').valueOf(); // 次日00:00:00 时间戳
startTime = targetMoment.startOf('day').millisecond(0).valueOf();
endTime = targetMoment.endOf('day').millisecond(0).valueOf();
}
// 2. 月维度当月1日0点 → 次月1日0点
// 2. 月维度当月1日00:00:00 → 当月最后一天23:59:59无毫秒
else if (this.activeTime === 1) {
startTime = targetMoment.startOf('month').valueOf(); // 当月1日00:00:00 时间戳
endTime = targetMoment.add(1, 'month').startOf('month').valueOf(); // 次月1日00:00:00 时间戳
startTime = targetMoment.startOf('month').millisecond(0).valueOf();
endTime = targetMoment.endOf('month').millisecond(0).valueOf();
}
// 3. 年维度当年1月1日0点 → 次年1月1日0点
// 3. 年维度当年1月1日00:00:00 → 当年最后一天23:59:59无毫秒
else if (this.activeTime === 2) {
startTime = targetMoment.startOf('year').valueOf(); // 当年1月1日00:00:00 时间戳
endTime = targetMoment.add(1, 'year').startOf('year').valueOf(); // 次年1月1日00:00:00 时间戳
startTime = targetMoment.startOf('year').millisecond(0).valueOf();
endTime = targetMoment.endOf('year').millisecond(0).valueOf();
}
// 调试输出(格式化显示,便于验证)
// 调试输出:验证是否去掉毫秒
console.log('时间范围计算结果:', {
mode,
startTime: moment(startTime).format('YYYY-MM-DD HH:mm:ss'),
endTime: moment(endTime).format('YYYY-MM-DD HH:mm:ss'),
startTimeStamp: startTime,
endTimeStamp: endTime
startTime: moment(startTime * 1000).format('YYYY-MM-DD HH:mm:ss'), // 格式2025-11-30 00:00:00
endTime: moment(endTime * 1000).format('YYYY-MM-DD HH:mm:ss'), // 格式2025-11-30 23:59:59无毫秒
startTimeStamp: startTime, // 秒级时间戳1764422400
endTimeStamp: endTime // 秒级时间戳1764508799
});
return { startTime, endTime, mode };

View File

@@ -162,9 +162,9 @@ export default {
getData(obj) {
// obj.levelId = 1
getCostAnalysisList({
startTime: 1762704000000,
endTime: 1762790400000,
mode:1
startTime: obj.startTime,
endTime: obj.endTime,
mode: obj.mode,
}).then((res) => {
this.costOverviews = res.data.costOverviews
this.piecesCostViews = res.data.piecesCostViews

View File

@@ -111,44 +111,40 @@ export default {
const mode = this.activeTime + 1; // 1=日2=月3=年
const defaultMoment = moment(); // 默认当前时间
// 处理选择的日期转为moment对象兼容不同选择器格式
console.log('this.date', this.date);
const targetMoment = this.date
? moment(this.date, this.getPickerType === 'date' ? 'YYYY-MM-DD' : (this.getPickerType === 'month' ? 'YYYY-MM' : 'YYYY'))
: defaultMoment;
// 验证日期有效性
if (!targetMoment.isValid()) {
console.error('无效日期:', this.date);
return { startTime, endTime, mode };
}
// 1. 日维度:当天0点 → 次日0点
// 1. 日维度:00:00:00 → 23:59:59无毫秒
if (this.activeTime === 0) {
startTime = targetMoment.startOf('day').valueOf(); // 当天00:00:00 时间戳
endTime = targetMoment.add(1, 'day').startOf('day').valueOf(); // 次日00:00:00 时间戳
startTime = targetMoment.startOf('day').millisecond(0).valueOf();
endTime = targetMoment.endOf('day').millisecond(0).valueOf();
}
// 2. 月维度当月1日0点 → 次月1日0点
// 2. 月维度当月1日00:00:00 → 当月最后一天23:59:59无毫秒
else if (this.activeTime === 1) {
startTime = targetMoment.startOf('month').valueOf(); // 当月1日00:00:00 时间戳
endTime = targetMoment.add(1, 'month').startOf('month').valueOf(); // 次月1日00:00:00 时间戳
startTime = targetMoment.startOf('month').millisecond(0).valueOf();
endTime = targetMoment.endOf('month').millisecond(0).valueOf();
}
// 3. 年维度当年1月1日0点 → 次年1月1日0点
// 3. 年维度当年1月1日00:00:00 → 当年最后一天23:59:59无毫秒
else if (this.activeTime === 2) {
startTime = targetMoment.startOf('year').valueOf(); // 当年1月1日00:00:00 时间戳
endTime = targetMoment.add(1, 'year').startOf('year').valueOf(); // 次年1月1日00:00:00 时间戳
startTime = targetMoment.startOf('year').millisecond(0).valueOf();
endTime = targetMoment.endOf('year').millisecond(0).valueOf();
}
// 调试输出(格式化显示,便于验证)
// 调试输出:验证是否去掉毫秒
console.log('时间范围计算结果:', {
mode,
startTime: moment(startTime).format('YYYY-MM-DD HH:mm:ss'),
endTime: moment(endTime).format('YYYY-MM-DD HH:mm:ss'),
startTimeStamp: startTime,
endTimeStamp: endTime
startTime: moment(startTime * 1000).format('YYYY-MM-DD HH:mm:ss'), // 格式2025-11-30 00:00:00
endTime: moment(endTime * 1000).format('YYYY-MM-DD HH:mm:ss'), // 格式2025-11-30 23:59:59无毫秒
startTimeStamp: startTime, // 秒级时间戳1764422400
endTimeStamp: endTime // 秒级时间戳1764508799
});
return { startTime, endTime, mode };

View File

@@ -110,44 +110,40 @@ export default {
const mode = this.activeTime + 1; // 1=日2=月3=年
const defaultMoment = moment(); // 默认当前时间
// 处理选择的日期转为moment对象兼容不同选择器格式
console.log('this.date', this.date);
const targetMoment = this.date
? moment(this.date, this.getPickerType === 'date' ? 'YYYY-MM-DD' : (this.getPickerType === 'month' ? 'YYYY-MM' : 'YYYY'))
: defaultMoment;
// 验证日期有效性
if (!targetMoment.isValid()) {
console.error('无效日期:', this.date);
return { startTime, endTime, mode };
}
// 1. 日维度:当天0点 → 次日0点
// 1. 日维度:00:00:00 → 23:59:59无毫秒
if (this.activeTime === 0) {
startTime = targetMoment.startOf('day').valueOf(); // 当天00:00:00 时间戳
endTime = targetMoment.add(1, 'day').startOf('day').valueOf(); // 次日00:00:00 时间戳
startTime = targetMoment.startOf('day').millisecond(0).valueOf();
endTime = targetMoment.endOf('day').millisecond(0).valueOf();
}
// 2. 月维度当月1日0点 → 次月1日0点
// 2. 月维度当月1日00:00:00 → 当月最后一天23:59:59无毫秒
else if (this.activeTime === 1) {
startTime = targetMoment.startOf('month').valueOf(); // 当月1日00:00:00 时间戳
endTime = targetMoment.add(1, 'month').startOf('month').valueOf(); // 次月1日00:00:00 时间戳
startTime = targetMoment.startOf('month').millisecond(0).valueOf();
endTime = targetMoment.endOf('month').millisecond(0).valueOf();
}
// 3. 年维度当年1月1日0点 → 次年1月1日0点
// 3. 年维度当年1月1日00:00:00 → 当年最后一天23:59:59无毫秒
else if (this.activeTime === 2) {
startTime = targetMoment.startOf('year').valueOf(); // 当年1月1日00:00:00 时间戳
endTime = targetMoment.add(1, 'year').startOf('year').valueOf(); // 次年1月1日00:00:00 时间戳
startTime = targetMoment.startOf('year').millisecond(0).valueOf();
endTime = targetMoment.endOf('year').millisecond(0).valueOf();
}
// 调试输出(格式化显示,便于验证)
// 调试输出:验证是否去掉毫秒
console.log('时间范围计算结果:', {
mode,
startTime: moment(startTime).format('YYYY-MM-DD HH:mm:ss'),
endTime: moment(endTime).format('YYYY-MM-DD HH:mm:ss'),
startTimeStamp: startTime,
endTimeStamp: endTime
startTime: moment(startTime * 1000).format('YYYY-MM-DD HH:mm:ss'), // 格式2025-11-30 00:00:00
endTime: moment(endTime * 1000).format('YYYY-MM-DD HH:mm:ss'), // 格式2025-11-30 23:59:59无毫秒
startTimeStamp: startTime, // 秒级时间戳1764422400
endTimeStamp: endTime // 秒级时间戳1764508799
});
return { startTime, endTime, mode };

View File

@@ -169,9 +169,9 @@ export default {
// startTime: this.startTime,
// endTime: this.endTime,
// mode: this.mode,
startTime: 1762704000000,
endTime: 1762790400000,
mode: 1,
startTime: this.dateData.startTime,
endTime: this.dateData.endTime,
mode: this.dateData.mode,
trendName: "燃料成本",
levelId: this.levelId ? this.levelId :1
};

View File

@@ -170,9 +170,9 @@ export default {
// startTime: this.startTime,
// endTime: this.endTime,
// mode: this.mode,
startTime: 1762704000000,
endTime: 1762790400000,
mode: 1,
startTime: this.dateData.startTime,
endTime: this.dateData.endTime,
mode: this.dateData.mode,
trendName: "燃动力成本",
levelId: this.levelId ? this.levelId : 1
};

View File

@@ -22,7 +22,7 @@
grid-template-columns: 560px 745px 560px ;
">
<coreBottomLeft :purchase="purchase" :inventory="inventory" />
<orderProgress @getData="getOrderData" :baseOrder="baseOrder" :orderOutput="orderOutput" />
<orderProgress @getData="getOrderData" :baseOrder="orderTableData" :orderOutput="orderOutput" />
<keyWork :importantWork="importantWork" />
</div>
</div>
@@ -39,7 +39,7 @@ import coreBottomLeft from './components/coreBottomLeft.vue'
import orderProgress from './components/orderProgress.vue'
import keyWork from './components/keyWork.vue'
// import moment from 'moment'
import { getOperateCockpit } from '@/api/cockpit'
import { getOperateCockpit, getOrderDetail } from '@/api/cockpit'
export default {
name: 'DayReport',
components: { ReportHeader, coreSalesKPIs, keyProductionIndicators, coreBottomLeft, keyWork, orderProgress, financeCosts },
@@ -49,6 +49,7 @@ export default {
timer: null,
beilv: 1,
value: 100,
orderTableData:[],
productData: {},
purchase: {},
dateData:{},
@@ -107,13 +108,14 @@ export default {
}
},
methods: {
getOrderData(num) {
this.getData({
startTime: this.dateData.startTime,
endTime: this.dateData.endTime,
timeDim: this.dateData.mode,
async getOrderData(num) {
const res = await getOrderDetail({
// startTime: this.dateData.startTime,
// endTime: this.dateData.endTime,
// timeDim: this.dateData.mode,
baseId: num
})
this.orderTableData = res.data
},
getData(obj) {
console.log('obj', obj);

View File

@@ -143,7 +143,7 @@ export default {
getSalesRevenueData({
startTime: obj.startTime,
endTime: obj.endTime,
timeDim: 1
timeDim: obj.mode
}).then((res) => {
console.log(res);
this.saleData = res.data.SaleData

View File

@@ -170,9 +170,9 @@ export default {
// startTime: this.startTime,
// endTime: this.endTime,
// mode: this.mode,
startTime: 1762704000000,
endTime: 1762790400000,
mode: 1,
startTime: this.dateData.startTime,
endTime: this.dateData.endTime,
mode: this.dateData.mode,
trendName: "包装物辅材成本",
levelId: this.levelId ? this.levelId : 1
};

View File

@@ -170,9 +170,9 @@ export default {
// startTime: this.startTime,
// endTime: this.endTime,
// mode: this.mode,
startTime: 1762704000000,
endTime: 1762790400000,
mode: 1,
startTime: this.dateData.startTime,
endTime: this.dateData.endTime,
mode: this.dateData.mode,
trendName: "制造费用成本",
levelId: this.levelId ? this.levelId : 1
};

View File

@@ -158,9 +158,9 @@ export default {
methods: {
getData(obj) {
getProfitAnalysisData({
startTime: 1762704000000,
endTime: 1762790400000,
mode: 1
startTime: obj.startTime,
endTime: obj.endTime,
mode: obj.mode,
}).then((res) => {
this.profitTotalData = res.data.overviewProfitData.filter(item => {

View File

@@ -160,9 +160,9 @@ export default {
// startTime: this.startTime,
// endTime: this.endTime,
// mode: this.mode,
startTime: 1762704000290,
endTime: 1762790399290,
mode: 1,
startTime: this.dateData.startTime,
endTime: this.dateData.endTime,
mode: this.dateData.mode,
// analysisObject: this.analysisObject,
analysisObject: ["石灰石"],
levelId: this.levelId ? this.levelId : 1

View File

@@ -156,11 +156,11 @@ export default {
// this.dateData = obj
// console.log('obj', obj);
getCostAnalysisXXCostList({
startTime: "1762704000290",
endTime: "1762790399290",
mode: 1,
startTime: this.dateData.startTime,
endTime: this.dateData.endTime,
mode: this.dateData.mode,
trendName: "原料成本",
levelId: 2
levelId: this.levelId
}).then((res) => {
this.itemData = res.data[0].map((item) => {
return {

View File

@@ -185,9 +185,9 @@ export default {
// startTime: this.startTime,
// endTime: this.endTime,
// mode: this.mode,
startTime: 1762704000000,
endTime: 1762790400000,
mode: 1,
startTime: this.dateData.startTime,
endTime: this.dateData.endTime,
mode: this.dateData.mode,
analysisObject: this.analysisObject,
levelId: this.levelId ? this.levelId : 1
};

View File

@@ -186,9 +186,9 @@ export default {
// startTime: this.startTime,
// endTime: this.endTime,
// mode: this.mode,
startTime: 1762704000000,
endTime: 1762790400000,
mode: 1,
startTime: this.dateData.startTime,
endTime: this.dateData.endTime,
mode: this.dateData.mode,
analysisObject: this.analysisObject,
levelId: this.levelId ? this.levelId : 1
};

View File

@@ -180,9 +180,9 @@ export default {
// startTime: this.startTime,
// endTime: this.endTime,
// mode: this.mode,
startTime: 1762704000000,
endTime: 1762790400000,
mode: 1,
startTime: this.dateData.startTime,
endTime: this.dateData.endTime,
mode: this.dateData.mode,
analysisObject: this.analysisObject,
levelId: this.levelId ? this.levelId : 1
};

View File

@@ -186,9 +186,9 @@ export default {
// startTime: this.startTime,
// endTime: this.endTime,
// mode: this.mode,
startTime: 1762704000000,
endTime: 1762790400000,
mode: 1,
startTime: this.dateData.startTime,
endTime: this.dateData.endTime,
mode: this.dateData.mode,
analysisObject: this.analysisObject,
levelId: this.levelId ? this.levelId : 1
};

View File

@@ -1,16 +1,16 @@
'use strict'
const path = require('path')
const defaultSettings = require('./src/settings.js')
"use strict";
const path = require("path");
const defaultSettings = require("./src/settings.js");
function resolve(dir) {
return path.join(__dirname, dir)
return path.join(__dirname, dir);
}
const CompressionPlugin = require('compression-webpack-plugin')
const CompressionPlugin = require("compression-webpack-plugin");
const name = process.env.VUE_APP_TITLE || "洛玻集团驾驶舱"; // 网页标题
const port = process.env.port || process.env.npm_config_port || 80 // 端口
const port = process.env.port || process.env.npm_config_port || 80; // 端口
// vue.config.js 配置说明
//官方vue.config.js 参考文档 https://cli.vuejs.org/zh/config/#css-loaderoptions
@@ -19,120 +19,115 @@ module.exports = {
// 部署生产环境和开发环境下的URL。
// 默认情况下Vue CLI 会假设你的应用是被部署在一个域名的根路径上
// 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。
publicPath: process.env.PUBLIC_PATH ? process.env.PUBLIC_PATH : '/',
publicPath: process.env.PUBLIC_PATH ? process.env.PUBLIC_PATH : "/",
// 在npm run build 或 yarn build 时 生成文件的目录名称要和baseUrl的生产环境路径一致默认dist
outputDir: 'dist',
outputDir: "dist",
// 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下)
assetsDir: 'static',
assetsDir: "static",
// 是否开启eslint保存检测有效值ture | false | 'error'
lintOnSave: process.env.NODE_ENV === 'development',
lintOnSave: process.env.NODE_ENV === "development",
// 如果你不需要生产环境的 source map可以将其设置为 false 以加速生产环境构建。
productionSourceMap: false,
// webpack-dev-server 相关配置
devServer: {
host: '0.0.0.0',
host: "0.0.0.0",
port: port,
open: true,
proxy: {
// detail: https://cli.vuejs.org/config/#devserver-proxy
['/proxy-api']: {
["/proxy-api"]: {
target: `http://localhost:48080`,
// target: `http://api-dashboard.yudao.iocoder.cn`,
changeOrigin: true,
pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: ''
}
}
["^" + process.env.VUE_APP_BASE_API]: "",
},
},
},
disableHostCheck: true
disableHostCheck: true,
},
css: {
loaderOptions: {
sass: {
sassOptions: { outputStyle: "expanded" }
}
}
sassOptions: { outputStyle: "expanded" },
},
},
},
configureWebpack: {
name: name,
resolve: {
alias: {
'@': resolve('src')
}
"@": resolve("src"),
},
},
plugins: [
// http://doc.ruoyi.vip/ruoyi-vue/other/faq.html#使用gzip解压缩静态文件
new CompressionPlugin({
cache: false, // 不启用文件缓存
test: /\.(js|css|html)?$/i, // 压缩文件格式
filename: '[path].gz[query]', // 压缩后的文件名
algorithm: 'gzip', // 使用gzip压缩
minRatio: 0.8 // 压缩率小于1才会压缩
})
cache: false, // 不启用文件缓存
test: /\.(js|css|html)?$/i, // 压缩文件格式
filename: "[path].gz[query]", // 压缩后的文件名
algorithm: "gzip", // 使用gzip压缩
minRatio: 0.8, // 压缩率小于1才会压缩
}),
],
},
chainWebpack(config) {
config.plugins.delete('preload') // TODO: need test
config.plugins.delete('prefetch') // TODO: need test
config.plugins.delete("preload"); // TODO: need test
config.plugins.delete("prefetch"); // TODO: need test
// set svg-sprite-loader
config.module.rule("svg").exclude.add(resolve("src/assets/icons")).end();
config.module
.rule('svg')
.exclude.add(resolve('src/assets/icons'))
.end()
config.module
.rule('icons')
.rule("icons")
.test(/\.svg$/)
.include.add(resolve('src/assets/icons'))
.include.add(resolve("src/assets/icons"))
.end()
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
.use("svg-sprite-loader")
.loader("svg-sprite-loader")
.options({
symbolId: 'icon-[name]'
symbolId: "icon-[name]",
})
.end()
.end();
config
.when(process.env.NODE_ENV !== 'development',
config => {
config
.plugin('ScriptExtHtmlWebpackPlugin')
.after('html')
.use('script-ext-html-webpack-plugin', [{
// `runtime` must same as runtimeChunk name. default is `runtime`
inline: /runtime\..*\.js$/
}])
.end()
config
.optimization.splitChunks({
chunks: 'all',
cacheGroups: {
libs: {
name: 'chunk-libs',
test: /[\\/]node_modules[\\/]/,
priority: 10,
chunks: 'initial' // only package third parties that are initially dependent
},
elementUI: {
name: 'chunk-elementUI', // split elementUI into a single package
priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm
},
commons: {
name: 'chunk-commons',
test: resolve('src/components'), // can customize your rules
minChunks: 3, // minimum common number
priority: 5,
reuseExistingChunk: true
}
}
})
config.optimization.runtimeChunk('single'),
config.when(process.env.NODE_ENV !== "development", (config) => {
config
.plugin("ScriptExtHtmlWebpackPlugin")
.after("html")
.use("script-ext-html-webpack-plugin", [
{
from: path.resolve(__dirname, './public/robots.txt'), //防爬虫文件
to: './', //到根目录下
}
}
)
}
}
// `runtime` must same as runtimeChunk name. default is `runtime`
inline: /runtime\..*\.js$/,
},
])
.end();
config.optimization.splitChunks({
chunks: "all",
cacheGroups: {
libs: {
name: "chunk-libs",
test: /[\\/]node_modules[\\/]/,
priority: 10,
chunks: "initial", // only package third parties that are initially dependent
},
elementUI: {
name: "chunk-elementUI", // split elementUI into a single package
priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
test: /[\\/]node_modules[\\/]_?element-ui(.*)/, // in order to adapt to cnpm
},
commons: {
name: "chunk-commons",
test: resolve("src/components"), // can customize your rules
minChunks: 3, // minimum common number
priority: 5,
reuseExistingChunk: true,
},
},
});
config.optimization.runtimeChunk("single"),
{
from: path.resolve(__dirname, "./public/robots.txt"), //防爬虫文件
to: "./", //到根目录下
};
});
},
};