fix(拆包优化): 修复部分异步加载的包出现 LoadingError

--bug=1026921 --user=白奇 【测试跟踪】项目设置-文件管理页面-跳转至测试跟踪页面失败 https://www.tapd.cn/55049933/s/1381589
This commit is contained in:
baiqi 2023-06-14 11:17:45 +08:00 committed by 刘瑞斌
parent e5dda8d9a7
commit 9e603821f2
16 changed files with 528 additions and 442 deletions

View File

@ -8,6 +8,7 @@
<title><%= htmlWebpackPlugin.options.title %></title> <title><%= htmlWebpackPlugin.options.title %></title>
<% if (process.env.NODE_ENV==='development' ) { %> <% if (process.env.NODE_ENV==='development' ) { %>
<link rel="stylesheet" href="http://localhost:3000/js/dev/element-ui/element-ui.css" /> <link rel="stylesheet" href="http://localhost:3000/js/dev/element-ui/element-ui.css" />
<script src="http://localhost:3000/js/dev/qiankun.umd.js"></script>
<script src="http://localhost:3000/js/dev/vue.js"></script> <script src="http://localhost:3000/js/dev/vue.js"></script>
<script src="http://localhost:3000/js/dev/element-ui/element-ui.js"></script> <script src="http://localhost:3000/js/dev/element-ui/element-ui.js"></script>
<script src="http://localhost:3000/js/dev/vue-router.js"></script> <script src="http://localhost:3000/js/dev/vue-router.js"></script>
@ -15,6 +16,7 @@
<script src="http://localhost:3000/js/prd/mavon-editor.js"></script> <script src="http://localhost:3000/js/prd/mavon-editor.js"></script>
<% } else { %> <% } else { %>
<link rel="stylesheet" href="<%= BASE_URL %>js/prd/element-ui/element-ui.min.css" /> <link rel="stylesheet" href="<%= BASE_URL %>js/prd/element-ui/element-ui.min.css" />
<script src="<%= BASE_URL %>js/prd/qiankun.umd.min.js"></script>
<script src="<%= BASE_URL %>js/prd/vue.min.js"></script> <script src="<%= BASE_URL %>js/prd/vue.min.js"></script>
<script src="<%= BASE_URL %>js/prd/element-ui/element-ui.min.js"></script> <script src="<%= BASE_URL %>js/prd/element-ui/element-ui.min.js"></script>
<script src="<%= BASE_URL %>js/prd/vue-router.min.js"></script> <script src="<%= BASE_URL %>js/prd/vue-router.min.js"></script>

View File

@ -52,9 +52,9 @@ module.exports = {
resolve: { resolve: {
alias: { alias: {
'@': resolve('src'), '@': resolve('src'),
'mockjs': resolve('node_modules/mockjs'), mockjs: resolve('node_modules/mockjs'),
'vue-i18n': resolve('node_modules/vue-i18n'), 'vue-i18n': resolve('node_modules/vue-i18n'),
'jsondiffpatch': resolve('node_modules/jsondiffpatch'), jsondiffpatch: resolve('node_modules/jsondiffpatch'),
}, },
}, },
output: { output: {
@ -67,12 +67,13 @@ module.exports = {
chunkFilename: `js/${name}-[name].[contenthash:8].js`, chunkFilename: `js/${name}-[name].[contenthash:8].js`,
}, },
externals: { externals: {
qiankun: 'qiankun',
vue: 'Vue', vue: 'Vue',
'element-ui': 'ELEMENT',
'vue-router': 'VueRouter', 'vue-router': 'VueRouter',
// 'echarts': 'echarts', // 'echarts': 'echarts',
// 'echarts/core': 'echarts', // TODO:外链使用的话需要改造导入及 vue-echarts 的源码 // 'echarts/core': 'echarts', // TODO:外链使用的话需要改造导入及 vue-echarts 的源码
// brace: 'brace', // TODO:暂时未发现能外链的方法本体包未提供cdn 外链形式的包 // brace: 'brace', // TODO:暂时未发现能外链的方法本体包未提供cdn 外链形式的包
'element-ui': 'ELEMENT',
'mavon-editor': 'MavonEditor', 'mavon-editor': 'MavonEditor',
'vue-shepherd': 'VueShepherd', 'vue-shepherd': 'VueShepherd',
}, },
@ -96,19 +97,43 @@ module.exports = {
html2canvas: { html2canvas: {
test: /[\\/]html2canvas[\\/]/, test: /[\\/]html2canvas[\\/]/,
name: 'html2canvas', name: 'html2canvas',
priority: 2, priority: 3,
chunks: 'all', chunks: 'all',
}, },
fortawesome: { fortawesome: {
test: /[\\/]@fortawesome[\\/]/, test: /[\\/]@fortawesome[\\/]/,
name: 'fortawesome', name: 'fortawesome',
priority: 2, priority: 3,
chunks: 'all', chunks: 'all',
}, },
'el-tree-transfer': { 'el-tree-transfer': {
test: /[\\/]el-tree-transfer[\\/]/, test: /[\\/]el-tree-transfer[\\/]/,
name: 'el-tree-transfer', name: 'el-tree-transfer',
priority: 2, priority: 3,
chunks: 'all',
},
jspdf: {
test: /[\\/]jspdf[\\/]/,
name: 'jspdf',
priority: 3,
chunks: 'all',
},
jsondiffpatch: {
test: /[\\/]jsondiffpatch[\\/]/,
name: 'jsondiffpatch',
priority: 3,
chunks: 'all',
},
jsencrypt: {
test: /[\\/]jsencrypt[\\/]/,
name: 'jsencrypt',
priority: 3,
chunks: 'all',
},
mockjs: {
test: /[\\/]mockjs[\\/]/,
name: 'mockjs',
priority: 3,
chunks: 'all', chunks: 'all',
}, },
pinia: { pinia: {
@ -129,30 +154,6 @@ module.exports = {
priority: 3, priority: 3,
chunks: 'all', 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',
},
}, },
}, },
}, },

View File

@ -1,5 +1,6 @@
const path = require('path'); const path = require("path");
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; const BundleAnalyzerPlugin =
require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
function resolve(dir) { function resolve(dir) {
return path.join(__dirname, dir); return path.join(__dirname, dir);
@ -10,117 +11,114 @@ module.exports = {
devServer: { devServer: {
port: 3000, port: 3000,
client: { client: {
webSocketTransport: 'sockjs', webSocketTransport: "sockjs",
}, },
webSocketServer: 'sockjs', webSocketServer: "sockjs",
allowedHosts: 'all', allowedHosts: "all",
proxy: { proxy: {
['^((?!/login)(?!/document))']: { ["^((?!/login)(?!/document))"]: {
target: 'http://localhost:8000', target: "http://localhost:8000",
ws: false ws: false,
}, },
'/websocket': { "/websocket": {
target: 'http://localhost:8000', target: "http://localhost:8000",
ws: true ws: true,
}, },
}, },
}, },
configureWebpack: { configureWebpack: {
devtool: 'cheap-module-source-map', devtool: "cheap-module-source-map",
resolve: { resolve: {
alias: { alias: {
'@': resolve('src') "@": resolve("src"),
} },
}, },
externals: { externals: {
vue: 'Vue', qiankun: "qiankun",
'vue-router': 'VueRouter', vue: "Vue",
qiankun: 'qiankun', "vue-router": "VueRouter",
// 'echarts': 'echarts', // 'echarts': 'echarts',
// 'echarts/core': 'echarts', // TODO:外链使用的话需要改造导入及 vue-echarts 的源码 // 'echarts/core': 'echarts', // TODO:外链使用的话需要改造导入及 vue-echarts 的源码
// brace: 'brace', // TODO:暂时未发现能外链的方法本体包未提供cdn 外链形式的包 // brace: 'brace', // TODO:暂时未发现能外链的方法本体包未提供cdn 外链形式的包
'element-ui': 'ELEMENT', "element-ui": "ELEMENT",
'vue-shepherd': 'VueShepherd', "vue-shepherd": "VueShepherd",
}, },
optimization: { optimization: {
splitChunks: { splitChunks: {
cacheGroups: { cacheGroups: {
'chunk-vendors': { "chunk-vendors": {
test: /[\\/]node_modules[\\/]/, test: /[\\/]node_modules[\\/]/,
name: 'chunk-vendors', name: "chunk-vendors",
priority: 1, priority: 1,
minChunks: 3, minChunks: 3,
chunks: 'all', chunks: "all",
}, },
'chunk-common': { "chunk-common": {
test: /[\\/]src[\\/]/, test: /[\\/]src[\\/]/,
name: 'chunk-common', name: "chunk-common",
priority: 1, priority: 1,
minChunks: 5, minChunks: 5,
chunks: 'all', chunks: "all",
}, },
html2canvas: { html2canvas: {
test: /[\\/]html2canvas[\\/]/, test: /[\\/]html2canvas[\\/]/,
name: 'html2canvas', name: "html2canvas",
priority: 2, priority: 3,
chunks: 'all', chunks: "all",
}, },
fortawesome: { fortawesome: {
test: /[\\/]@fortawesome[\\/]/, test: /[\\/]@fortawesome[\\/]/,
name: 'fortawesome', name: "fortawesome",
priority: 2,
chunks: 'all',
},
pinia: {
test: /[\\/]pinia[\\/]/,
name: 'pinia',
priority: 3, priority: 3,
chunks: 'all', chunks: "all",
}, },
jspdf: { jspdf: {
test: /[\\/]jspdf[\\/]/, test: /[\\/]jspdf[\\/]/,
name: 'jspdf', name: "jspdf",
priority: 2, priority: 3,
chunks: 'all', chunks: "all",
}, },
jsencrypt: { jsencrypt: {
test: /[\\/]jsencrypt[\\/]/, test: /[\\/]jsencrypt[\\/]/,
name: 'jsencrypt', name: "jsencrypt",
priority: 2, priority: 3,
chunks: 'all', chunks: "all",
},
pinia: {
test: /[\\/]pinia[\\/]/,
name: "pinia",
priority: 3,
chunks: "all",
}, },
}, },
}, },
}, },
}, },
chainWebpack: config => { chainWebpack: (config) => {
config.devtool('source-map') config.devtool("source-map");
config.resolve.alias.set('@', resolve('./src')) config.resolve.alias.set("@", resolve("./src"));
config.output.library("MsFrontend") config.output.library("MsFrontend");
config.module.rule("svg").exclude.add(resolve("src/assets/module")).end();
config.module config.module
.rule('svg') .rule("icons")
.exclude.add(resolve('src/assets/module'))
.end()
config.module
.rule('icons')
.test(/\.svg$/) .test(/\.svg$/)
.include.add(resolve('src/assets/module')) .include.add(resolve("src/assets/module"))
.end() .end()
.use('svg-sprite-loader') .use("svg-sprite-loader")
.loader('svg-sprite-loader') .loader("svg-sprite-loader")
.options({ .options({
symbolId: 'icon-[name]' symbolId: "icon-[name]",
}) });
if (process.env.NODE_ENV === 'analyze') { if (process.env.NODE_ENV === "analyze") {
config.plugin('webpack-report').use(BundleAnalyzerPlugin, [ config.plugin("webpack-report").use(BundleAnalyzerPlugin, [
{ {
analyzerMode: 'static', analyzerMode: "static",
reportFilename: './webpack-report.html', reportFilename: "./webpack-report.html",
openAnalyzer: false, openAnalyzer: false,
}, },
]); ]);
} }
} },
}; };

View File

@ -1,33 +1,44 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang=""> <html lang="">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> <link rel="icon" href="<%= BASE_URL %>favicon.ico" />
<title><%= htmlWebpackPlugin.options.title %></title> <title><%= htmlWebpackPlugin.options.title %></title>
<% if (process.env.NODE_ENV==='development' ) { %> <% if (process.env.NODE_ENV==='development' ) { %>
<link rel="stylesheet" href="http://localhost:3000/js/dev/element-ui/element-ui.css" /> <link
rel="stylesheet"
href="http://localhost:3000/js/dev/element-ui/element-ui.css"
/>
<script src="http://localhost:3000/js/dev/qiankun.umd.js"></script>
<script src="http://localhost:3000/js/dev/vue.js"></script> <script src="http://localhost:3000/js/dev/vue.js"></script>
<script src="http://localhost:3000/js/dev/element-ui/element-ui.js"></script> <script src="http://localhost:3000/js/dev/element-ui/element-ui.js"></script>
<script src="http://localhost:3000/js/dev/vue-router.js"></script> <script src="http://localhost:3000/js/dev/vue-router.js"></script>
<script src="http://localhost:3000/js/prd/vue-shepherd.min.js"></script> <script src="http://localhost:3000/js/prd/vue-shepherd.min.js"></script>
<script src="http://localhost:3000/js/prd/mavon-editor.js"></script> <script src="http://localhost:3000/js/prd/mavon-editor.js"></script>
<% } else { %> <% } else { %>
<link rel="stylesheet" href="<%= BASE_URL %>js/prd/element-ui/element-ui.min.css" /> <link
rel="stylesheet"
href="<%= BASE_URL %>js/prd/element-ui/element-ui.min.css"
/>
<script src="<%= BASE_URL %>js/prd/qiankun.umd.min.js"></script>
<script src="<%= BASE_URL %>js/prd/vue.min.js"></script> <script src="<%= BASE_URL %>js/prd/vue.min.js"></script>
<script src="<%= BASE_URL %>js/prd/element-ui/element-ui.min.js"></script> <script src="<%= BASE_URL %>js/prd/element-ui/element-ui.min.js"></script>
<script src="<%= BASE_URL %>js/prd/vue-router.min.js"></script> <script src="<%= BASE_URL %>js/prd/vue-router.min.js"></script>
<script src="<%= BASE_URL %>js/prd/vue-shepherd.min.js"></script> <script src="<%= BASE_URL %>js/prd/vue-shepherd.min.js"></script>
<script src="<%= BASE_URL %>js/prd/mavon-editor.js"></script> <script src="<%= BASE_URL %>js/prd/mavon-editor.js"></script>
<% } %> <% } %>
</head> </head>
<body> <body>
<noscript> <noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to <strong
continue.</strong> >We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work
</noscript> properly without JavaScript enabled. Please enable it to
<div id="app"></div> continue.</strong
<!-- built files will be auto injected --> >
</body> </noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html> </html>

View File

@ -50,8 +50,8 @@ module.exports = {
resolve: { resolve: {
alias: { alias: {
"@": resolve("src"), "@": resolve("src"),
'html2canvas': resolve('node_modules/html2canvas'), html2canvas: resolve("node_modules/html2canvas"),
'vue-i18n': resolve('node_modules/vue-i18n'), "vue-i18n": resolve("node_modules/vue-i18n"),
}, },
fallback: { stream: require.resolve("stream-browserify") }, fallback: { stream: require.resolve("stream-browserify") },
}, },
@ -65,12 +65,13 @@ module.exports = {
chunkFilename: `js/${name}-[name].[contenthash:8].js`, chunkFilename: `js/${name}-[name].[contenthash:8].js`,
}, },
externals: { externals: {
qiankun: "qiankun",
vue: "Vue", vue: "Vue",
"element-ui": "ELEMENT",
"vue-router": "VueRouter", "vue-router": "VueRouter",
// 'echarts': 'echarts', // 'echarts': 'echarts',
// 'echarts/core': 'echarts', // TODO:外链使用的话需要改造导入及 vue-echarts 的源码 // 'echarts/core': 'echarts', // TODO:外链使用的话需要改造导入及 vue-echarts 的源码
// brace: 'brace', // TODO:暂时未发现能外链的方法本体包未提供cdn 外链形式的包 // brace: 'brace', // TODO:暂时未发现能外链的方法本体包未提供cdn 外链形式的包
"element-ui": "ELEMENT",
"mavon-editor": "MavonEditor", "mavon-editor": "MavonEditor",
"vue-shepherd": "VueShepherd", "vue-shepherd": "VueShepherd",
}, },
@ -94,19 +95,43 @@ module.exports = {
html2canvas: { html2canvas: {
test: /[\\/]html2canvas[\\/]/, test: /[\\/]html2canvas[\\/]/,
name: "html2canvas", name: "html2canvas",
priority: 2, priority: 3,
chunks: "all", chunks: "all",
}, },
fortawesome: { fortawesome: {
test: /[\\/]@fortawesome[\\/]/, test: /[\\/]@fortawesome[\\/]/,
name: "fortawesome", name: "fortawesome",
priority: 2, priority: 3,
chunks: "all", chunks: "all",
}, },
"el-tree-transfer": { "el-tree-transfer": {
test: /[\\/]el-tree-transfer[\\/]/, test: /[\\/]el-tree-transfer[\\/]/,
name: "el-tree-transfer", name: "el-tree-transfer",
priority: 2, priority: 3,
chunks: "all",
},
jspdf: {
test: /[\\/]jspdf[\\/]/,
name: "jspdf",
priority: 3,
chunks: "all",
},
jsondiffpatch: {
test: /[\\/]jsondiffpatch[\\/]/,
name: "jsondiffpatch",
priority: 3,
chunks: "all",
},
jsencrypt: {
test: /[\\/]jsencrypt[\\/]/,
name: "jsencrypt",
priority: 3,
chunks: "all",
},
mockjs: {
test: /[\\/]mockjs[\\/]/,
name: "mockjs",
priority: 3,
chunks: "all", chunks: "all",
}, },
pinia: { pinia: {
@ -127,30 +152,6 @@ module.exports = {
priority: 3, priority: 3,
chunks: "all", 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",
},
}, },
}, },
}, },

View File

@ -1,33 +1,44 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang=""> <html lang="">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> <link rel="icon" href="<%= BASE_URL %>favicon.ico" />
<title><%= htmlWebpackPlugin.options.title %></title> <title><%= htmlWebpackPlugin.options.title %></title>
<% if (process.env.NODE_ENV==='development' ) { %> <% if (process.env.NODE_ENV==='development' ) { %>
<link rel="stylesheet" href="http://localhost:3000/js/dev/element-ui/element-ui.css" /> <link
rel="stylesheet"
href="http://localhost:3000/js/dev/element-ui/element-ui.css"
/>
<script src="http://localhost:3000/js/dev/qiankun.umd.js"></script>
<script src="http://localhost:3000/js/dev/vue.js"></script> <script src="http://localhost:3000/js/dev/vue.js"></script>
<script src="http://localhost:3000/js/dev/element-ui/element-ui.js"></script> <script src="http://localhost:3000/js/dev/element-ui/element-ui.js"></script>
<script src="http://localhost:3000/js/dev/vue-router.js"></script> <script src="http://localhost:3000/js/dev/vue-router.js"></script>
<script src="http://localhost:3000/js/prd/vue-shepherd.min.js"></script> <script src="http://localhost:3000/js/prd/vue-shepherd.min.js"></script>
<script src="http://localhost:3000/js/prd/mavon-editor.js"></script> <script src="http://localhost:3000/js/prd/mavon-editor.js"></script>
<% } else { %> <% } else { %>
<link rel="stylesheet" href="<%= BASE_URL %>js/prd/element-ui/element-ui.min.css" /> <link
rel="stylesheet"
href="<%= BASE_URL %>js/prd/element-ui/element-ui.min.css"
/>
<script src="<%= BASE_URL %>js/prd/qiankun.umd.min.js"></script>
<script src="<%= BASE_URL %>js/prd/vue.min.js"></script> <script src="<%= BASE_URL %>js/prd/vue.min.js"></script>
<script src="<%= BASE_URL %>js/prd/element-ui/element-ui.min.js"></script> <script src="<%= BASE_URL %>js/prd/element-ui/element-ui.min.js"></script>
<script src="<%= BASE_URL %>js/prd/vue-router.min.js"></script> <script src="<%= BASE_URL %>js/prd/vue-router.min.js"></script>
<script src="<%= BASE_URL %>js/prd/vue-shepherd.min.js"></script> <script src="<%= BASE_URL %>js/prd/vue-shepherd.min.js"></script>
<script src="<%= BASE_URL %>js/prd/mavon-editor.js"></script> <script src="<%= BASE_URL %>js/prd/mavon-editor.js"></script>
<% } %> <% } %>
</head> </head>
<body> <body>
<noscript> <noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to <strong
continue.</strong> >We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work
</noscript> properly without JavaScript enabled. Please enable it to
<div id="app"></div> continue.</strong
<!-- built files will be auto injected --> >
</body> </noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html> </html>

View File

@ -36,8 +36,8 @@ module.exports = {
resolve: { resolve: {
alias: { alias: {
"@": resolve("src"), "@": resolve("src"),
'vue-i18n': resolve('node_modules/vue-i18n'), "vue-i18n": resolve("node_modules/vue-i18n"),
'jsondiffpatch': resolve('node_modules/jsondiffpatch'), jsondiffpatch: resolve("node_modules/jsondiffpatch"),
}, },
}, },
output: { output: {
@ -50,12 +50,13 @@ module.exports = {
chunkFilename: `js/${name}-[name].[contenthash:8].js`, chunkFilename: `js/${name}-[name].[contenthash:8].js`,
}, },
externals: { externals: {
qiankun: "qiankun",
vue: "Vue", vue: "Vue",
"element-ui": "ELEMENT",
"vue-router": "VueRouter", "vue-router": "VueRouter",
// 'echarts': 'echarts', // 'echarts': 'echarts',
// 'echarts/core': 'echarts', // TODO:外链使用的话需要改造导入及 vue-echarts 的源码 // 'echarts/core': 'echarts', // TODO:外链使用的话需要改造导入及 vue-echarts 的源码
// brace: 'brace', // TODO:暂时未发现能外链的方法本体包未提供cdn 外链形式的包 // brace: 'brace', // TODO:暂时未发现能外链的方法本体包未提供cdn 外链形式的包
"element-ui": "ELEMENT",
"mavon-editor": "MavonEditor", "mavon-editor": "MavonEditor",
"vue-shepherd": "VueShepherd", "vue-shepherd": "VueShepherd",
}, },
@ -79,19 +80,43 @@ module.exports = {
html2canvas: { html2canvas: {
test: /[\\/]html2canvas[\\/]/, test: /[\\/]html2canvas[\\/]/,
name: "html2canvas", name: "html2canvas",
priority: 2, priority: 3,
chunks: "all", chunks: "all",
}, },
fortawesome: { fortawesome: {
test: /[\\/]@fortawesome[\\/]/, test: /[\\/]@fortawesome[\\/]/,
name: "fortawesome", name: "fortawesome",
priority: 2, priority: 3,
chunks: "all", chunks: "all",
}, },
"el-tree-transfer": { "el-tree-transfer": {
test: /[\\/]el-tree-transfer[\\/]/, test: /[\\/]el-tree-transfer[\\/]/,
name: "el-tree-transfer", name: "el-tree-transfer",
priority: 2, priority: 3,
chunks: "all",
},
jspdf: {
test: /[\\/]jspdf[\\/]/,
name: "jspdf",
priority: 3,
chunks: "all",
},
jsondiffpatch: {
test: /[\\/]jsondiffpatch[\\/]/,
name: "jsondiffpatch",
priority: 3,
chunks: "all",
},
jsencrypt: {
test: /[\\/]jsencrypt[\\/]/,
name: "jsencrypt",
priority: 3,
chunks: "all",
},
mockjs: {
test: /[\\/]mockjs[\\/]/,
name: "mockjs",
priority: 3,
chunks: "all", chunks: "all",
}, },
pinia: { pinia: {
@ -106,30 +131,6 @@ module.exports = {
priority: 3, priority: 3,
chunks: "all", 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",
},
}, },
}, },
}, },

View File

@ -1,33 +1,44 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang=""> <html lang="">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> <link rel="icon" href="<%= BASE_URL %>favicon.ico" />
<title><%= htmlWebpackPlugin.options.title %></title> <title><%= htmlWebpackPlugin.options.title %></title>
<% if (process.env.NODE_ENV==='development' ) { %> <% if (process.env.NODE_ENV==='development' ) { %>
<link rel="stylesheet" href="http://localhost:3000/js/dev/element-ui/element-ui.css" /> <link
rel="stylesheet"
href="http://localhost:3000/js/dev/element-ui/element-ui.css"
/>
<script src="http://localhost:3000/js/dev/qiankun.umd.js"></script>
<script src="http://localhost:3000/js/dev/vue.js"></script> <script src="http://localhost:3000/js/dev/vue.js"></script>
<script src="http://localhost:3000/js/dev/element-ui/element-ui.js"></script> <script src="http://localhost:3000/js/dev/element-ui/element-ui.js"></script>
<script src="http://localhost:3000/js/dev/vue-router.js"></script> <script src="http://localhost:3000/js/dev/vue-router.js"></script>
<script src="http://localhost:3000/js/prd/vue-shepherd.min.js"></script> <script src="http://localhost:3000/js/prd/vue-shepherd.min.js"></script>
<script src="http://localhost:3000/js/prd/mavon-editor.js"></script> <script src="http://localhost:3000/js/prd/mavon-editor.js"></script>
<% } else { %> <% } else { %>
<link rel="stylesheet" href="<%= BASE_URL %>js/prd/element-ui/element-ui.min.css" /> <link
rel="stylesheet"
href="<%= BASE_URL %>js/prd/element-ui/element-ui.min.css"
/>
<script src="<%= BASE_URL %>js/prd/qiankun.umd.min.js"></script>
<script src="<%= BASE_URL %>js/prd/vue.min.js"></script> <script src="<%= BASE_URL %>js/prd/vue.min.js"></script>
<script src="<%= BASE_URL %>js/prd/element-ui/element-ui.min.js"></script> <script src="<%= BASE_URL %>js/prd/element-ui/element-ui.min.js"></script>
<script src="<%= BASE_URL %>js/prd/vue-router.min.js"></script> <script src="<%= BASE_URL %>js/prd/vue-router.min.js"></script>
<script src="<%= BASE_URL %>js/prd/vue-shepherd.min.js"></script> <script src="<%= BASE_URL %>js/prd/vue-shepherd.min.js"></script>
<script src="<%= BASE_URL %>js/prd/mavon-editor.js"></script> <script src="<%= BASE_URL %>js/prd/mavon-editor.js"></script>
<% } %> <% } %>
</head> </head>
<body> <body>
<noscript> <noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to <strong
continue.</strong> >We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work
</noscript> properly without JavaScript enabled. Please enable it to
<div id="app"></div> continue.</strong
<!-- built files will be auto injected --> >
</body> </noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html> </html>

View File

@ -48,8 +48,8 @@ module.exports = {
resolve: { resolve: {
alias: { alias: {
"@": resolve("src"), "@": resolve("src"),
'vue-i18n': resolve('node_modules/vue-i18n'), "vue-i18n": resolve("node_modules/vue-i18n"),
'html2canvas': resolve('node_modules/html2canvas'), html2canvas: resolve("node_modules/html2canvas"),
}, },
}, },
output: { output: {
@ -62,12 +62,13 @@ module.exports = {
chunkFilename: `js/${name}-[name].[contenthash:8].js`, chunkFilename: `js/${name}-[name].[contenthash:8].js`,
}, },
externals: { externals: {
qiankun: "qiankun",
vue: "Vue", vue: "Vue",
"element-ui": "ELEMENT",
"vue-router": "VueRouter", "vue-router": "VueRouter",
// 'echarts': 'echarts', // 'echarts': 'echarts',
// 'echarts/core': 'echarts', // TODO:外链使用的话需要改造导入及 vue-echarts 的源码 // 'echarts/core': 'echarts', // TODO:外链使用的话需要改造导入及 vue-echarts 的源码
// brace: 'brace', // TODO:暂时未发现能外链的方法本体包未提供cdn 外链形式的包 // brace: 'brace', // TODO:暂时未发现能外链的方法本体包未提供cdn 外链形式的包
"element-ui": "ELEMENT",
"mavon-editor": "MavonEditor", "mavon-editor": "MavonEditor",
"vue-shepherd": "VueShepherd", "vue-shepherd": "VueShepherd",
}, },
@ -91,19 +92,31 @@ module.exports = {
html2canvas: { html2canvas: {
test: /[\\/]html2canvas[\\/]/, test: /[\\/]html2canvas[\\/]/,
name: "html2canvas", name: "html2canvas",
priority: 2, priority: 3,
chunks: "all", chunks: "all",
}, },
fortawesome: { fortawesome: {
test: /[\\/]@fortawesome[\\/]/, test: /[\\/]@fortawesome[\\/]/,
name: "fortawesome", name: "fortawesome",
priority: 2, priority: 3,
chunks: "all", chunks: "all",
}, },
"el-tree-transfer": { "el-tree-transfer": {
test: /[\\/]el-tree-transfer[\\/]/, test: /[\\/]el-tree-transfer[\\/]/,
name: "el-tree-transfer", name: "el-tree-transfer",
priority: 2, priority: 3,
chunks: "all",
},
jspdf: {
test: /[\\/]jspdf[\\/]/,
name: "jspdf",
priority: 3,
chunks: "all",
},
jsencrypt: {
test: /[\\/]jsencrypt[\\/]/,
name: "jsencrypt",
priority: 3,
chunks: "all", chunks: "all",
}, },
pinia: { pinia: {
@ -124,18 +137,6 @@ module.exports = {
priority: 3, priority: 3,
chunks: "all", chunks: "all",
}, },
jspdf: {
test: /[\\/]jspdf[\\/]/,
name: "jspdf",
priority: 2,
chunks: "all",
},
jsencrypt: {
test: /[\\/]jsencrypt[\\/]/,
name: "jsencrypt",
priority: 2,
chunks: "all",
},
}, },
}, },
}, },

View File

@ -1,33 +1,44 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang=""> <html lang="">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> <link rel="icon" href="<%= BASE_URL %>favicon.ico" />
<title><%= htmlWebpackPlugin.options.title %></title> <title><%= htmlWebpackPlugin.options.title %></title>
<% if (process.env.NODE_ENV==='development' ) { %> <% if (process.env.NODE_ENV==='development' ) { %>
<link rel="stylesheet" href="http://localhost:3000/js/dev/element-ui/element-ui.css" /> <link
rel="stylesheet"
href="http://localhost:3000/js/dev/element-ui/element-ui.css"
/>
<script src="http://localhost:3000/js/dev/qiankun.umd.js"></script>
<script src="http://localhost:3000/js/dev/vue.js"></script> <script src="http://localhost:3000/js/dev/vue.js"></script>
<script src="http://localhost:3000/js/dev/element-ui/element-ui.js"></script> <script src="http://localhost:3000/js/dev/element-ui/element-ui.js"></script>
<script src="http://localhost:3000/js/dev/vue-router.js"></script> <script src="http://localhost:3000/js/dev/vue-router.js"></script>
<script src="http://localhost:3000/js/prd/vue-shepherd.min.js"></script> <script src="http://localhost:3000/js/prd/vue-shepherd.min.js"></script>
<script src="http://localhost:3000/js/prd/mavon-editor.js"></script> <script src="http://localhost:3000/js/prd/mavon-editor.js"></script>
<% } else { %> <% } else { %>
<link rel="stylesheet" href="<%= BASE_URL %>js/prd/element-ui/element-ui.min.css" /> <link
rel="stylesheet"
href="<%= BASE_URL %>js/prd/element-ui/element-ui.min.css"
/>
<script src="<%= BASE_URL %>js/prd/qiankun.umd.min.js"></script>
<script src="<%= BASE_URL %>js/prd/vue.min.js"></script> <script src="<%= BASE_URL %>js/prd/vue.min.js"></script>
<script src="<%= BASE_URL %>js/prd/element-ui/element-ui.min.js"></script> <script src="<%= BASE_URL %>js/prd/element-ui/element-ui.min.js"></script>
<script src="<%= BASE_URL %>js/prd/vue-router.min.js"></script> <script src="<%= BASE_URL %>js/prd/vue-router.min.js"></script>
<script src="<%= BASE_URL %>js/prd/vue-shepherd.min.js"></script> <script src="<%= BASE_URL %>js/prd/vue-shepherd.min.js"></script>
<script src="<%= BASE_URL %>js/prd/mavon-editor.js"></script> <script src="<%= BASE_URL %>js/prd/mavon-editor.js"></script>
<% } %> <% } %>
</head> </head>
<body> <body>
<noscript> <noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to <strong
continue.</strong> >We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work
</noscript> properly without JavaScript enabled. Please enable it to
<div id="app"></div> continue.</strong
<!-- built files will be auto injected --> >
</body> </noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html> </html>

View File

@ -36,8 +36,8 @@ module.exports = {
resolve: { resolve: {
alias: { alias: {
"@": resolve("src"), "@": resolve("src"),
'vue-i18n': resolve('node_modules/vue-i18n'), "vue-i18n": resolve("node_modules/vue-i18n"),
'jsondiffpatch': resolve('node_modules/jsondiffpatch'), jsondiffpatch: resolve("node_modules/jsondiffpatch"),
}, },
}, },
output: { output: {
@ -50,12 +50,13 @@ module.exports = {
chunkFilename: `js/${name}-[name].[contenthash:8].js`, chunkFilename: `js/${name}-[name].[contenthash:8].js`,
}, },
externals: { externals: {
qiankun: "qiankun",
vue: "Vue", vue: "Vue",
"element-ui": "ELEMENT",
"vue-router": "VueRouter", "vue-router": "VueRouter",
// 'echarts': 'echarts', // 'echarts': 'echarts',
// 'echarts/core': 'echarts', // TODO:外链使用的话需要改造导入及 vue-echarts 的源码 // 'echarts/core': 'echarts', // TODO:外链使用的话需要改造导入及 vue-echarts 的源码
// brace: 'brace', // TODO:暂时未发现能外链的方法本体包未提供cdn 外链形式的包 // brace: 'brace', // TODO:暂时未发现能外链的方法本体包未提供cdn 外链形式的包
"element-ui": "ELEMENT",
"mavon-editor": "MavonEditor", "mavon-editor": "MavonEditor",
"vue-shepherd": "VueShepherd", "vue-shepherd": "VueShepherd",
}, },
@ -79,19 +80,43 @@ module.exports = {
html2canvas: { html2canvas: {
test: /[\\/]html2canvas[\\/]/, test: /[\\/]html2canvas[\\/]/,
name: "html2canvas", name: "html2canvas",
priority: 2, priority: 3,
chunks: "all", chunks: "all",
}, },
fortawesome: { fortawesome: {
test: /[\\/]@fortawesome[\\/]/, test: /[\\/]@fortawesome[\\/]/,
name: "fortawesome", name: "fortawesome",
priority: 2, priority: 3,
chunks: "all", chunks: "all",
}, },
"el-tree-transfer": { "el-tree-transfer": {
test: /[\\/]el-tree-transfer[\\/]/, test: /[\\/]el-tree-transfer[\\/]/,
name: "el-tree-transfer", name: "el-tree-transfer",
priority: 2, priority: 3,
chunks: "all",
},
jspdf: {
test: /[\\/]jspdf[\\/]/,
name: "jspdf",
priority: 3,
chunks: "all",
},
jsondiffpatch: {
test: /[\\/]jsondiffpatch[\\/]/,
name: "jsondiffpatch",
priority: 3,
chunks: "all",
},
jsencrypt: {
test: /[\\/]jsencrypt[\\/]/,
name: "jsencrypt",
priority: 3,
chunks: "all",
},
mockjs: {
test: /[\\/]mockjs[\\/]/,
name: "mockjs",
priority: 3,
chunks: "all", chunks: "all",
}, },
pinia: { pinia: {
@ -106,30 +131,6 @@ module.exports = {
priority: 3, priority: 3,
chunks: "all", 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",
},
}, },
}, },
}, },

View File

@ -42,6 +42,7 @@
"lodash.isnumber": "^3.0.3", "lodash.isnumber": "^3.0.3",
"lodash.isobject": "^3.0.2", "lodash.isobject": "^3.0.2",
"lodash.isstring": "^4.0.1", "lodash.isstring": "^4.0.1",
"lodash-es": "^4.17.21",
"mavon-editor": "2.10.4", "mavon-editor": "2.10.4",
"md5": "^2.3.0", "md5": "^2.3.0",
"metersphere-frontend": "file:../../framework/sdk-parent/frontend", "metersphere-frontend": "file:../../framework/sdk-parent/frontend",

View File

@ -1,33 +1,44 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang=""> <html lang="">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> <link rel="icon" href="<%= BASE_URL %>favicon.ico" />
<title><%= htmlWebpackPlugin.options.title %></title> <title><%= htmlWebpackPlugin.options.title %></title>
<% if (process.env.NODE_ENV==='development' ) { %> <% if (process.env.NODE_ENV==='development' ) { %>
<link rel="stylesheet" href="http://localhost:3000/js/dev/element-ui/element-ui.css" /> <link
rel="stylesheet"
href="http://localhost:3000/js/dev/element-ui/element-ui.css"
/>
<script src="http://localhost:3000/js/dev/qiankun.umd.js"></script>
<script src="http://localhost:3000/js/dev/vue.js"></script> <script src="http://localhost:3000/js/dev/vue.js"></script>
<script src="http://localhost:3000/js/dev/element-ui/element-ui.js"></script> <script src="http://localhost:3000/js/dev/element-ui/element-ui.js"></script>
<script src="http://localhost:3000/js/dev/vue-router.js"></script> <script src="http://localhost:3000/js/dev/vue-router.js"></script>
<script src="http://localhost:3000/js/prd/vue-shepherd.min.js"></script> <script src="http://localhost:3000/js/prd/vue-shepherd.min.js"></script>
<script src="http://localhost:3000/js/prd/mavon-editor.js"></script> <script src="http://localhost:3000/js/prd/mavon-editor.js"></script>
<% } else { %> <% } else { %>
<link rel="stylesheet" href="<%= BASE_URL %>js/prd/element-ui/element-ui.min.css" /> <link
rel="stylesheet"
href="<%= BASE_URL %>js/prd/element-ui/element-ui.min.css"
/>
<script src="<%= BASE_URL %>js/prd/qiankun.umd.min.js"></script>
<script src="<%= BASE_URL %>js/prd/vue.min.js"></script> <script src="<%= BASE_URL %>js/prd/vue.min.js"></script>
<script src="<%= BASE_URL %>js/prd/element-ui/element-ui.min.js"></script> <script src="<%= BASE_URL %>js/prd/element-ui/element-ui.min.js"></script>
<script src="<%= BASE_URL %>js/prd/vue-router.min.js"></script> <script src="<%= BASE_URL %>js/prd/vue-router.min.js"></script>
<script src="<%= BASE_URL %>js/prd/vue-shepherd.min.js"></script> <script src="<%= BASE_URL %>js/prd/vue-shepherd.min.js"></script>
<script src="<%= BASE_URL %>js/prd/mavon-editor.js"></script> <script src="<%= BASE_URL %>js/prd/mavon-editor.js"></script>
<% } %> <% } %>
</head> </head>
<body> <body>
<noscript> <noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to <strong
continue.</strong> >We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work
</noscript> properly without JavaScript enabled. Please enable it to
<div id="app"></div> continue.</strong
<!-- built files will be auto injected --> >
</body> </noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html> </html>

View File

@ -1,10 +1,11 @@
const path = require('path'); const path = require("path");
const {name} = require('./package'); const { name } = require("./package");
const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin') const HtmlWebpackInlineSourcePlugin = require("html-webpack-inline-source-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackPlugin = require("html-webpack-plugin");
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; const BundleAnalyzerPlugin =
const InlineSourceWebpackPlugin = require('inline-source-webpack-plugin'); require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
const InlineSourceWebpackPlugin = require("inline-source-webpack-plugin");
function resolve(dir) { function resolve(dir) {
return path.join(__dirname, dir); return path.join(__dirname, dir);
@ -15,68 +16,71 @@ module.exports = {
devServer: { devServer: {
port: 4005, port: 4005,
client: { client: {
webSocketTransport: 'sockjs', webSocketTransport: "sockjs",
}, },
allowedHosts: 'all', allowedHosts: "all",
webSocketServer: 'sockjs', webSocketServer: "sockjs",
proxy: { proxy: {
['^((?!/login)(?!/document))']: { ["^((?!/login)(?!/document))"]: {
target: 'http://localhost:8005', target: "http://localhost:8005",
ws: false ws: false,
}, },
'/websocket': { "/websocket": {
target: 'http://localhost:8005', target: "http://localhost:8005",
ws: true ws: true,
}, },
}, },
// 跨域 // 跨域
headers: { headers: {
'Access-Control-Allow-Origin': '*', "Access-Control-Allow-Origin": "*",
}, },
}, },
pages: { pages: {
business: { business: {
entry: "src/main.js", entry: "src/main.js",
template: "public/index.html", template: "public/index.html",
filename: "index.html" filename: "index.html",
}, },
sharePlanReport: { sharePlanReport: {
entry: "src/business/template/report/plan/share/share-plan-report.js", entry: "src/business/template/report/plan/share/share-plan-report.js",
template: "src/business/template/report/plan/share/share-plan-report.html", template:
"src/business/template/report/plan/share/share-plan-report.html",
filename: "share-plan-report.html", filename: "share-plan-report.html",
}, },
planReport: { //这个配置要放最后不然会导致测试计划导出报告没有将css和js引入html原因没具体研究 planReport: {
//这个配置要放最后不然会导致测试计划导出报告没有将css和js引入html原因没具体研究
entry: "src/business/template/report/plan/plan-report.js", entry: "src/business/template/report/plan/plan-report.js",
template: "src/business/template/report/plan/plan-report.html", template: "src/business/template/report/plan/plan-report.html",
filename: "plan-report.html", filename: "plan-report.html",
inlineSource: '.*' inlineSource: ".*",
} },
}, },
configureWebpack: { configureWebpack: {
devtool: 'cheap-module-source-map', devtool: "cheap-module-source-map",
resolve: { resolve: {
alias: { alias: {
'@': resolve('src'), "@": resolve("src"),
'vue-i18n': resolve('node_modules/vue-i18n'), "vue-i18n": resolve("node_modules/vue-i18n"),
}, },
fallback: {"stream": require.resolve("stream-browserify")} fallback: { stream: require.resolve("stream-browserify") },
}, },
output: { output: {
// 把子应用打包成 umd 库格式(必须) // 把子应用打包成 umd 库格式(必须)
library: `${name}-[name]`, library: `${name}-[name]`,
libraryTarget: 'umd', libraryTarget: "umd",
chunkLoadingGlobal: `webpackJsonp_${name}`, chunkLoadingGlobal: `webpackJsonp_${name}`,
// 打包后js的名称 // 打包后js的名称
filename: `js/${name}-[name].[contenthash:8].js`, filename: `js/${name}-[name].[contenthash:8].js`,
chunkFilename: `js/${name}-[name].[contenthash:8].js`, chunkFilename: `js/${name}-[name].[contenthash:8].js`,
}, },
externals: { externals: {
qiankun: "qiankun",
vue: "Vue", vue: "Vue",
"element-ui": "ELEMENT",
"vue-router": "VueRouter", "vue-router": "VueRouter",
// 'echarts': 'echarts', // 'echarts': 'echarts',
// 'echarts/core': 'echarts', // TODO:外链使用的话需要改造导入及 vue-echarts 的源码 // 'echarts/core': 'echarts', // TODO:外链使用的话需要改造导入及 vue-echarts 的源码
// brace: 'brace', // TODO:暂时未发现能外链的方法本体包未提供cdn 外链形式的包 // brace: 'brace', // TODO:暂时未发现能外链的方法本体包未提供cdn 外链形式的包
"element-ui": "ELEMENT",
"mavon-editor": "MavonEditor", "mavon-editor": "MavonEditor",
"vue-shepherd": "VueShepherd", "vue-shepherd": "VueShepherd",
}, },
@ -115,24 +119,6 @@ module.exports = {
priority: 2, priority: 2,
chunks: "all", chunks: "all",
}, },
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",
},
jspdf: { jspdf: {
test: /[\\/]jspdf[\\/]/, test: /[\\/]jspdf[\\/]/,
name: "jspdf", name: "jspdf",
@ -181,6 +167,24 @@ module.exports = {
priority: 2, priority: 2,
chunks: "all", chunks: "all",
}, },
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",
},
}, },
}, },
}, },
@ -193,46 +197,55 @@ module.exports = {
extract: { extract: {
ignoreOrder: true, ignoreOrder: true,
filename: `css/${name}-[name].[contenthash:8].css`, filename: `css/${name}-[name].[contenthash:8].css`,
chunkFilename: `css/${name}-[name].[contenthash:8].css` chunkFilename: `css/${name}-[name].[contenthash:8].css`,
}, },
}, },
chainWebpack: config => { chainWebpack: (config) => {
config.module config.module
.rule('svg') .rule("svg")
.exclude.add(resolve('../../framework/sdk-parent/frontend/src/assets/module')) .exclude.add(
.end() resolve("../../framework/sdk-parent/frontend/src/assets/module")
)
.end();
config.module config.module
.rule('icons') .rule("icons")
.test(/\.svg$/) .test(/\.svg$/)
.include.add(resolve('../../framework/sdk-parent/frontend/src/assets/module')) .include.add(
resolve("../../framework/sdk-parent/frontend/src/assets/module")
)
.end() .end()
.use('svg-sprite-loader') .use("svg-sprite-loader")
.loader('svg-sprite-loader') .loader("svg-sprite-loader")
.options({ .options({
symbolId: 'icon-[name]' symbolId: "icon-[name]",
}) });
// 报告模板打包成一个html // 报告模板打包成一个html
config.plugin('inline-source-html') config
.after('html-planReport') .plugin("inline-source-html")
.use(new InlineSourceWebpackPlugin({ .after("html-planReport")
.use(
new InlineSourceWebpackPlugin({
compress: true, compress: true,
rootpath: '../../framework/sdk-parent/frontend/public/js', rootpath: "../../framework/sdk-parent/frontend/public/js",
noAssetMatch: 'warn' noAssetMatch: "warn",
}), [HtmlWebpackPlugin]); }),
[HtmlWebpackPlugin]
);
config.plugin('inline-source-html-planReport') config
.after('html-planReport') .plugin("inline-source-html-planReport")
.after("html-planReport")
.use(HtmlWebpackInlineSourcePlugin, [HtmlWebpackPlugin]); .use(HtmlWebpackInlineSourcePlugin, [HtmlWebpackPlugin]);
if (process.env.NODE_ENV === 'analyze') { if (process.env.NODE_ENV === "analyze") {
config.plugin('webpack-report').use(BundleAnalyzerPlugin, [ config.plugin("webpack-report").use(BundleAnalyzerPlugin, [
{ {
analyzerMode: 'static', analyzerMode: "static",
reportFilename: './webpack-report.html', reportFilename: "./webpack-report.html",
openAnalyzer: false, openAnalyzer: false,
}, },
]); ]);
} }
} },
}; };

View File

@ -1,33 +1,44 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang=""> <html lang="">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> <link rel="icon" href="<%= BASE_URL %>favicon.ico" />
<title><%= htmlWebpackPlugin.options.title %></title> <title><%= htmlWebpackPlugin.options.title %></title>
<% if (process.env.NODE_ENV==='development' ) { %> <% if (process.env.NODE_ENV==='development' ) { %>
<link rel="stylesheet" href="http://localhost:3000/js/dev/element-ui/element-ui.css" /> <link
rel="stylesheet"
href="http://localhost:3000/js/dev/element-ui/element-ui.css"
/>
<script src="http://localhost:3000/js/dev/qiankun.umd.js"></script>
<script src="http://localhost:3000/js/dev/vue.js"></script> <script src="http://localhost:3000/js/dev/vue.js"></script>
<script src="http://localhost:3000/js/dev/element-ui/element-ui.js"></script> <script src="http://localhost:3000/js/dev/element-ui/element-ui.js"></script>
<script src="http://localhost:3000/js/dev/vue-router.js"></script> <script src="http://localhost:3000/js/dev/vue-router.js"></script>
<script src="http://localhost:3000/js/prd/vue-shepherd.min.js"></script> <script src="http://localhost:3000/js/prd/vue-shepherd.min.js"></script>
<script src="http://localhost:3000/js/prd/mavon-editor.js"></script> <script src="http://localhost:3000/js/prd/mavon-editor.js"></script>
<% } else { %> <% } else { %>
<link rel="stylesheet" href="<%= BASE_URL %>js/prd/element-ui/element-ui.min.css" /> <link
rel="stylesheet"
href="<%= BASE_URL %>js/prd/element-ui/element-ui.min.css"
/>
<script src="<%= BASE_URL %>js/prd/qiankun.umd.min.js"></script>
<script src="<%= BASE_URL %>js/prd/vue.min.js"></script> <script src="<%= BASE_URL %>js/prd/vue.min.js"></script>
<script src="<%= BASE_URL %>js/prd/element-ui/element-ui.min.js"></script> <script src="<%= BASE_URL %>js/prd/element-ui/element-ui.min.js"></script>
<script src="<%= BASE_URL %>js/prd/vue-router.min.js"></script> <script src="<%= BASE_URL %>js/prd/vue-router.min.js"></script>
<script src="<%= BASE_URL %>js/prd/vue-shepherd.min.js"></script> <script src="<%= BASE_URL %>js/prd/vue-shepherd.min.js"></script>
<script src="<%= BASE_URL %>js/prd/mavon-editor.js"></script> <script src="<%= BASE_URL %>js/prd/mavon-editor.js"></script>
<% } %> <% } %>
</head> </head>
<body> <body>
<noscript> <noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to <strong
continue.</strong> >We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work
</noscript> properly without JavaScript enabled. Please enable it to
<div id="app"></div> continue.</strong
<!-- built files will be auto injected --> >
</body> </noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html> </html>

View File

@ -36,7 +36,7 @@ module.exports = {
resolve: { resolve: {
alias: { alias: {
"@": resolve("src"), "@": resolve("src"),
'vue-i18n': resolve('node_modules/vue-i18n'), "vue-i18n": resolve("node_modules/vue-i18n"),
}, },
}, },
output: { output: {
@ -49,12 +49,13 @@ module.exports = {
chunkFilename: `js/${name}-[name].[contenthash:8].js`, chunkFilename: `js/${name}-[name].[contenthash:8].js`,
}, },
externals: { externals: {
qiankun: "qiankun",
vue: "Vue", vue: "Vue",
"element-ui": "ELEMENT",
"vue-router": "VueRouter", "vue-router": "VueRouter",
// 'echarts': 'echarts', // 'echarts': 'echarts',
// 'echarts/core': 'echarts', // TODO:外链使用的话需要改造导入及 vue-echarts 的源码 // 'echarts/core': 'echarts', // TODO:外链使用的话需要改造导入及 vue-echarts 的源码
// brace: 'brace', // TODO:暂时未发现能外链的方法本体包未提供cdn 外链形式的包 // brace: 'brace', // TODO:暂时未发现能外链的方法本体包未提供cdn 外链形式的包
"element-ui": "ELEMENT",
"mavon-editor": "MavonEditor", "mavon-editor": "MavonEditor",
"vue-shepherd": "VueShepherd", "vue-shepherd": "VueShepherd",
}, },
@ -78,19 +79,49 @@ module.exports = {
html2canvas: { html2canvas: {
test: /[\\/]html2canvas[\\/]/, test: /[\\/]html2canvas[\\/]/,
name: "html2canvas", name: "html2canvas",
priority: 2, priority: 3,
chunks: "all", chunks: "all",
}, },
fortawesome: { fortawesome: {
test: /[\\/]@fortawesome[\\/]/, test: /[\\/]@fortawesome[\\/]/,
name: "fortawesome", name: "fortawesome",
priority: 2, priority: 3,
chunks: "all", chunks: "all",
}, },
"el-tree-transfer": { "el-tree-transfer": {
test: /[\\/]el-tree-transfer[\\/]/, test: /[\\/]el-tree-transfer[\\/]/,
name: "el-tree-transfer", name: "el-tree-transfer",
priority: 2, priority: 3,
chunks: "all",
},
jspdf: {
test: /[\\/]jspdf[\\/]/,
name: "jspdf",
priority: 3,
chunks: "all",
},
sortablejs: {
test: /[\\/]sortablejs[\\/]/,
name: "sortablejs",
priority: 3,
chunks: "all",
},
jsencrypt: {
test: /[\\/]jsencrypt[\\/]/,
name: "jsencrypt",
priority: 3,
chunks: "all",
},
mockjs: {
test: /[\\/]mockjs[\\/]/,
name: "mockjs",
priority: 3,
chunks: "all",
},
lodash: {
test: /[\\/]lodash[\\/]/,
name: "lodash",
priority: 3,
chunks: "all", chunks: "all",
}, },
pinia: { pinia: {
@ -105,36 +136,6 @@ module.exports = {
priority: 3, priority: 3,
chunks: "all", chunks: "all",
}, },
jspdf: {
test: /[\\/]jspdf[\\/]/,
name: "jspdf",
priority: 2,
chunks: "all",
},
sortablejs: {
test: /[\\/]sortablejs[\\/]/,
name: "sortablejs",
priority: 2,
chunks: "all",
},
jsencrypt: {
test: /[\\/]jsencrypt[\\/]/,
name: "jsencrypt",
priority: 2,
chunks: "all",
},
mockjs: {
test: /[\\/]mockjs[\\/]/,
name: "mockjs",
priority: 2,
chunks: "all",
},
lodash: {
test: /[\\/]lodash[\\/]/,
name: "lodash",
priority: 2,
chunks: "all",
},
}, },
}, },
}, },