2023-06-14 11:17:45 +08:00
|
|
|
|
const path = require("path");
|
|
|
|
|
const { name } = require("./package");
|
2023-06-14 15:19:43 +08:00
|
|
|
|
const { defineConfig } = require("@vue/cli-service");
|
2022-10-10 13:41:39 +08:00
|
|
|
|
|
2023-06-14 11:17:45 +08:00
|
|
|
|
const HtmlWebpackInlineSourcePlugin = require("html-webpack-inline-source-plugin");
|
|
|
|
|
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
|
|
|
const BundleAnalyzerPlugin =
|
|
|
|
|
require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
|
|
|
|
|
const InlineSourceWebpackPlugin = require("inline-source-webpack-plugin");
|
2022-10-10 13:41:39 +08:00
|
|
|
|
|
|
|
|
|
function resolve(dir) {
|
|
|
|
|
return path.join(__dirname, dir);
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-14 18:04:37 +08:00
|
|
|
|
const proxyUrl = 'http://localhost:8005'
|
2023-06-15 17:56:43 +08:00
|
|
|
|
|
2023-06-14 15:19:43 +08:00
|
|
|
|
module.exports = defineConfig({
|
|
|
|
|
publicPath: "/",
|
2022-10-10 18:35:38 +08:00
|
|
|
|
productionSourceMap: false,
|
2022-10-10 13:41:39 +08:00
|
|
|
|
devServer: {
|
|
|
|
|
port: 4005,
|
|
|
|
|
client: {
|
2023-06-14 11:17:45 +08:00
|
|
|
|
webSocketTransport: "sockjs",
|
2023-07-02 12:14:54 +08:00
|
|
|
|
overlay: false,
|
2022-10-10 13:41:39 +08:00
|
|
|
|
},
|
2023-06-14 11:17:45 +08:00
|
|
|
|
allowedHosts: "all",
|
|
|
|
|
webSocketServer: "sockjs",
|
2022-10-10 13:41:39 +08:00
|
|
|
|
proxy: {
|
2023-06-14 11:17:45 +08:00
|
|
|
|
["^((?!/login)(?!/document))"]: {
|
2023-06-15 17:56:43 +08:00
|
|
|
|
target: proxyUrl,
|
2023-06-14 11:17:45 +08:00
|
|
|
|
ws: false,
|
2022-10-10 13:41:39 +08:00
|
|
|
|
},
|
2023-06-14 11:17:45 +08:00
|
|
|
|
"/websocket": {
|
2023-06-15 17:56:43 +08:00
|
|
|
|
target: proxyUrl,
|
2023-06-14 11:17:45 +08:00
|
|
|
|
ws: true,
|
2022-10-10 13:41:39 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
// 跨域
|
|
|
|
|
headers: {
|
2023-06-14 11:17:45 +08:00
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
2022-10-10 13:41:39 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
pages: {
|
|
|
|
|
business: {
|
|
|
|
|
entry: "src/main.js",
|
|
|
|
|
template: "public/index.html",
|
2023-06-14 11:17:45 +08:00
|
|
|
|
filename: "index.html",
|
2022-10-10 13:41:39 +08:00
|
|
|
|
},
|
|
|
|
|
sharePlanReport: {
|
|
|
|
|
entry: "src/business/template/report/plan/share/share-plan-report.js",
|
2023-06-14 11:17:45 +08:00
|
|
|
|
template:
|
|
|
|
|
"src/business/template/report/plan/share/share-plan-report.html",
|
2022-10-10 13:41:39 +08:00
|
|
|
|
filename: "share-plan-report.html",
|
|
|
|
|
},
|
2023-06-14 11:17:45 +08:00
|
|
|
|
planReport: {
|
|
|
|
|
//这个配置要放最后,不然会导致测试计划导出报告没有将css和js引入html,原因没具体研究
|
2022-10-10 13:41:39 +08:00
|
|
|
|
entry: "src/business/template/report/plan/plan-report.js",
|
|
|
|
|
template: "src/business/template/report/plan/plan-report.html",
|
|
|
|
|
filename: "plan-report.html",
|
2023-06-14 11:17:45 +08:00
|
|
|
|
inlineSource: ".*",
|
|
|
|
|
},
|
2022-10-10 13:41:39 +08:00
|
|
|
|
},
|
|
|
|
|
configureWebpack: {
|
2023-06-14 11:17:45 +08:00
|
|
|
|
devtool: "cheap-module-source-map",
|
2022-10-10 13:41:39 +08:00
|
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
2023-06-14 11:17:45 +08:00
|
|
|
|
"@": resolve("src"),
|
|
|
|
|
"vue-i18n": resolve("node_modules/vue-i18n"),
|
2022-10-10 13:41:39 +08:00
|
|
|
|
},
|
2023-06-14 11:17:45 +08:00
|
|
|
|
fallback: { stream: require.resolve("stream-browserify") },
|
2022-10-10 13:41:39 +08:00
|
|
|
|
},
|
|
|
|
|
output: {
|
|
|
|
|
// 把子应用打包成 umd 库格式(必须)
|
|
|
|
|
library: `${name}-[name]`,
|
2023-06-14 11:17:45 +08:00
|
|
|
|
libraryTarget: "umd",
|
2022-10-10 13:41:39 +08:00
|
|
|
|
chunkLoadingGlobal: `webpackJsonp_${name}`,
|
|
|
|
|
// 打包后js的名称
|
|
|
|
|
filename: `js/${name}-[name].[contenthash:8].js`,
|
|
|
|
|
chunkFilename: `js/${name}-[name].[contenthash:8].js`,
|
2023-05-29 11:52:29 +08:00
|
|
|
|
},
|
|
|
|
|
optimization: {
|
|
|
|
|
splitChunks: {
|
|
|
|
|
cacheGroups: {
|
|
|
|
|
"chunk-vendors": {
|
|
|
|
|
test: /[\\/]node_modules[\\/]/,
|
|
|
|
|
name: "chunk-vendors",
|
|
|
|
|
priority: 1,
|
|
|
|
|
minChunks: 3,
|
|
|
|
|
chunks: "all",
|
|
|
|
|
},
|
|
|
|
|
"chunk-common": {
|
|
|
|
|
test: /[\\/]src[\\/]/,
|
|
|
|
|
name: "chunk-common",
|
|
|
|
|
priority: 1,
|
|
|
|
|
minChunks: 5,
|
|
|
|
|
chunks: "all",
|
|
|
|
|
},
|
|
|
|
|
html2canvas: {
|
|
|
|
|
test: /[\\/]html2canvas[\\/]/,
|
|
|
|
|
name: "html2canvas",
|
|
|
|
|
priority: 2,
|
|
|
|
|
chunks: "all",
|
|
|
|
|
},
|
|
|
|
|
fortawesome: {
|
|
|
|
|
test: /[\\/]@fortawesome[\\/]/,
|
|
|
|
|
name: "fortawesome",
|
|
|
|
|
priority: 2,
|
|
|
|
|
chunks: "all",
|
|
|
|
|
},
|
|
|
|
|
"el-tree-transfer": {
|
|
|
|
|
test: /[\\/]el-tree-transfer[\\/]/,
|
|
|
|
|
name: "el-tree-transfer",
|
|
|
|
|
priority: 2,
|
|
|
|
|
chunks: "all",
|
|
|
|
|
},
|
|
|
|
|
jspdf: {
|
|
|
|
|
test: /[\\/]jspdf[\\/]/,
|
|
|
|
|
name: "jspdf",
|
|
|
|
|
priority: 2,
|
|
|
|
|
chunks: "all",
|
|
|
|
|
},
|
|
|
|
|
jsondiffpatch: {
|
|
|
|
|
test: /[\\/]jsondiffpatch[\\/]/,
|
|
|
|
|
name: "jsondiffpatch",
|
|
|
|
|
priority: 2,
|
|
|
|
|
chunks: "all",
|
|
|
|
|
},
|
|
|
|
|
jsencrypt: {
|
|
|
|
|
test: /[\\/]jsencrypt[\\/]/,
|
|
|
|
|
name: "jsencrypt",
|
|
|
|
|
priority: 2,
|
|
|
|
|
chunks: "all",
|
|
|
|
|
},
|
|
|
|
|
mockjs: {
|
|
|
|
|
test: /[\\/]mockjs[\\/]/,
|
|
|
|
|
name: "mockjs",
|
|
|
|
|
priority: 2,
|
|
|
|
|
chunks: "all",
|
|
|
|
|
},
|
|
|
|
|
pdfjs: {
|
|
|
|
|
test: /[\\/]pdfjs-dist[\\/]/,
|
|
|
|
|
name: "pdfjs",
|
|
|
|
|
priority: 2,
|
|
|
|
|
chunks: "all",
|
|
|
|
|
},
|
|
|
|
|
ckeditor: {
|
|
|
|
|
test: /[\\/]@ckeditor[\\/]/,
|
|
|
|
|
name: "ckeditor",
|
|
|
|
|
priority: 2,
|
|
|
|
|
chunks: "all",
|
|
|
|
|
},
|
|
|
|
|
minderEditor: {
|
|
|
|
|
test: /[\\/]vue-minder-editor-plus[\\/]/,
|
|
|
|
|
name: "minderEditor",
|
|
|
|
|
priority: 2,
|
|
|
|
|
chunks: "all",
|
|
|
|
|
},
|
|
|
|
|
lodash: {
|
|
|
|
|
test: /[\\/]lodash[\\/]/,
|
|
|
|
|
name: "lodash",
|
|
|
|
|
priority: 2,
|
|
|
|
|
chunks: "all",
|
|
|
|
|
},
|
2023-06-14 11:17:45 +08:00
|
|
|
|
pinia: {
|
|
|
|
|
test: /[\\/]pinia[\\/]/,
|
|
|
|
|
name: "pinia",
|
|
|
|
|
priority: 3,
|
|
|
|
|
chunks: "all",
|
|
|
|
|
},
|
|
|
|
|
brace: {
|
|
|
|
|
test: /[\\/]brace[\\/]/,
|
|
|
|
|
name: "brace",
|
|
|
|
|
priority: 3,
|
|
|
|
|
chunks: "all",
|
|
|
|
|
},
|
|
|
|
|
echarts: {
|
|
|
|
|
test: /[\\/](echarts|zrender)[\\/]/,
|
|
|
|
|
name: "echarts",
|
|
|
|
|
priority: 3,
|
|
|
|
|
chunks: "all",
|
|
|
|
|
},
|
2023-05-29 11:52:29 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2022-10-10 13:41:39 +08:00
|
|
|
|
},
|
|
|
|
|
css: {
|
|
|
|
|
// 将组件内的 CSS 提取到一个单独的 CSS 文件 (只用在生产环境中)
|
|
|
|
|
// 也可以是一个传递给 `extract-text-webpack-plugin` 的选项对象
|
|
|
|
|
// 修改打包后css文件名
|
|
|
|
|
// extract: true,
|
|
|
|
|
extract: {
|
|
|
|
|
ignoreOrder: true,
|
|
|
|
|
filename: `css/${name}-[name].[contenthash:8].css`,
|
2023-06-14 11:17:45 +08:00
|
|
|
|
chunkFilename: `css/${name}-[name].[contenthash:8].css`,
|
2022-10-10 13:41:39 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
2023-06-14 11:17:45 +08:00
|
|
|
|
chainWebpack: (config) => {
|
2022-10-10 13:41:39 +08:00
|
|
|
|
config.module
|
2023-06-14 11:17:45 +08:00
|
|
|
|
.rule("svg")
|
|
|
|
|
.exclude.add(
|
|
|
|
|
resolve("../../framework/sdk-parent/frontend/src/assets/module")
|
|
|
|
|
)
|
|
|
|
|
.end();
|
2022-10-10 13:41:39 +08:00
|
|
|
|
config.module
|
2023-06-14 11:17:45 +08:00
|
|
|
|
.rule("icons")
|
2022-10-10 13:41:39 +08:00
|
|
|
|
.test(/\.svg$/)
|
2023-06-14 11:17:45 +08:00
|
|
|
|
.include.add(
|
|
|
|
|
resolve("../../framework/sdk-parent/frontend/src/assets/module")
|
|
|
|
|
)
|
2022-10-10 13:41:39 +08:00
|
|
|
|
.end()
|
2023-06-14 11:17:45 +08:00
|
|
|
|
.use("svg-sprite-loader")
|
|
|
|
|
.loader("svg-sprite-loader")
|
2022-10-10 13:41:39 +08:00
|
|
|
|
.options({
|
2023-06-14 11:17:45 +08:00
|
|
|
|
symbolId: "icon-[name]",
|
|
|
|
|
});
|
2022-10-10 13:41:39 +08:00
|
|
|
|
|
|
|
|
|
// 报告模板打包成一个html
|
2023-06-14 11:17:45 +08:00
|
|
|
|
config
|
|
|
|
|
.plugin("inline-source-html")
|
|
|
|
|
.after("html-planReport")
|
|
|
|
|
.use(
|
|
|
|
|
new InlineSourceWebpackPlugin({
|
|
|
|
|
compress: true,
|
|
|
|
|
rootpath: "../../framework/sdk-parent/frontend/public/js",
|
|
|
|
|
noAssetMatch: "warn",
|
|
|
|
|
}),
|
|
|
|
|
[HtmlWebpackPlugin]
|
|
|
|
|
);
|
2023-05-29 11:52:29 +08:00
|
|
|
|
|
2023-06-14 11:17:45 +08:00
|
|
|
|
config
|
|
|
|
|
.plugin("inline-source-html-planReport")
|
|
|
|
|
.after("html-planReport")
|
2022-10-12 18:25:49 +08:00
|
|
|
|
.use(HtmlWebpackInlineSourcePlugin, [HtmlWebpackPlugin]);
|
2022-10-10 13:41:39 +08:00
|
|
|
|
|
2023-06-14 11:17:45 +08:00
|
|
|
|
if (process.env.NODE_ENV === "analyze") {
|
|
|
|
|
config.plugin("webpack-report").use(BundleAnalyzerPlugin, [
|
2023-05-29 11:52:29 +08:00
|
|
|
|
{
|
2023-06-14 11:17:45 +08:00
|
|
|
|
analyzerMode: "static",
|
|
|
|
|
reportFilename: "./webpack-report.html",
|
2023-05-29 11:52:29 +08:00
|
|
|
|
openAnalyzer: false,
|
|
|
|
|
},
|
|
|
|
|
]);
|
|
|
|
|
}
|
2023-06-14 11:17:45 +08:00
|
|
|
|
},
|
2023-06-14 15:19:43 +08:00
|
|
|
|
});
|