2023-06-14 11:17:45 +08:00
|
|
|
|
const path = require("path");
|
2023-06-14 15:19:43 +08:00
|
|
|
|
const { defineConfig } = require("@vue/cli-service");
|
2023-06-14 11:17:45 +08:00
|
|
|
|
const BundleAnalyzerPlugin =
|
|
|
|
|
require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
|
2022-10-10 13:41:39 +08:00
|
|
|
|
|
|
|
|
|
function resolve(dir) {
|
|
|
|
|
return path.join(__dirname, dir);
|
|
|
|
|
}
|
|
|
|
|
|
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: 3000,
|
|
|
|
|
client: {
|
2023-06-14 11:17:45 +08:00
|
|
|
|
webSocketTransport: "sockjs",
|
2022-10-10 13:41:39 +08:00
|
|
|
|
},
|
2023-06-14 11:17:45 +08:00
|
|
|
|
webSocketServer: "sockjs",
|
|
|
|
|
allowedHosts: "all",
|
2022-10-10 13:41:39 +08:00
|
|
|
|
proxy: {
|
2023-06-14 11:17:45 +08:00
|
|
|
|
["^((?!/login)(?!/document))"]: {
|
|
|
|
|
target: "http://localhost:8000",
|
|
|
|
|
ws: false,
|
2022-10-10 13:41:39 +08:00
|
|
|
|
},
|
2023-06-14 11:17:45 +08:00
|
|
|
|
"/websocket": {
|
|
|
|
|
target: "http://localhost:8000",
|
|
|
|
|
ws: true,
|
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"),
|
|
|
|
|
},
|
2022-10-10 13:41:39 +08:00
|
|
|
|
},
|
2023-05-29 11:52:29 +08:00
|
|
|
|
externals: {
|
2023-06-14 11:17:45 +08:00
|
|
|
|
qiankun: "qiankun",
|
|
|
|
|
vue: "Vue",
|
|
|
|
|
"vue-router": "VueRouter",
|
2023-05-29 11:52:29 +08:00
|
|
|
|
// 'echarts': 'echarts',
|
|
|
|
|
// 'echarts/core': 'echarts', // TODO:外链使用的话需要改造导入及 vue-echarts 的源码
|
|
|
|
|
// brace: 'brace', // TODO:暂时未发现能外链的方法,本体包未提供cdn 外链形式的包
|
2023-06-14 11:17:45 +08:00
|
|
|
|
"element-ui": "ELEMENT",
|
|
|
|
|
"vue-shepherd": "VueShepherd",
|
2023-05-29 11:52:29 +08:00
|
|
|
|
},
|
|
|
|
|
optimization: {
|
|
|
|
|
splitChunks: {
|
|
|
|
|
cacheGroups: {
|
2023-06-14 11:17:45 +08:00
|
|
|
|
"chunk-vendors": {
|
2023-05-29 11:52:29 +08:00
|
|
|
|
test: /[\\/]node_modules[\\/]/,
|
2023-06-14 11:17:45 +08:00
|
|
|
|
name: "chunk-vendors",
|
2023-05-29 11:52:29 +08:00
|
|
|
|
priority: 1,
|
|
|
|
|
minChunks: 3,
|
2023-06-14 11:17:45 +08:00
|
|
|
|
chunks: "all",
|
2023-05-29 11:52:29 +08:00
|
|
|
|
},
|
2023-06-14 11:17:45 +08:00
|
|
|
|
"chunk-common": {
|
2023-05-29 11:52:29 +08:00
|
|
|
|
test: /[\\/]src[\\/]/,
|
2023-06-14 11:17:45 +08:00
|
|
|
|
name: "chunk-common",
|
2023-05-29 11:52:29 +08:00
|
|
|
|
priority: 1,
|
|
|
|
|
minChunks: 5,
|
2023-06-14 11:17:45 +08:00
|
|
|
|
chunks: "all",
|
2023-05-29 11:52:29 +08:00
|
|
|
|
},
|
|
|
|
|
html2canvas: {
|
|
|
|
|
test: /[\\/]html2canvas[\\/]/,
|
2023-06-14 11:17:45 +08:00
|
|
|
|
name: "html2canvas",
|
|
|
|
|
priority: 3,
|
|
|
|
|
chunks: "all",
|
2023-05-29 11:52:29 +08:00
|
|
|
|
},
|
|
|
|
|
fortawesome: {
|
|
|
|
|
test: /[\\/]@fortawesome[\\/]/,
|
2023-06-14 11:17:45 +08:00
|
|
|
|
name: "fortawesome",
|
2023-05-29 11:52:29 +08:00
|
|
|
|
priority: 3,
|
2023-06-14 11:17:45 +08:00
|
|
|
|
chunks: "all",
|
2023-05-29 11:52:29 +08:00
|
|
|
|
},
|
|
|
|
|
jspdf: {
|
|
|
|
|
test: /[\\/]jspdf[\\/]/,
|
2023-06-14 11:17:45 +08:00
|
|
|
|
name: "jspdf",
|
|
|
|
|
priority: 3,
|
|
|
|
|
chunks: "all",
|
2023-05-29 11:52:29 +08:00
|
|
|
|
},
|
|
|
|
|
jsencrypt: {
|
|
|
|
|
test: /[\\/]jsencrypt[\\/]/,
|
2023-06-14 11:17:45 +08:00
|
|
|
|
name: "jsencrypt",
|
|
|
|
|
priority: 3,
|
|
|
|
|
chunks: "all",
|
|
|
|
|
},
|
|
|
|
|
pinia: {
|
|
|
|
|
test: /[\\/]pinia[\\/]/,
|
|
|
|
|
name: "pinia",
|
|
|
|
|
priority: 3,
|
|
|
|
|
chunks: "all",
|
2023-05-29 11:52:29 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2022-10-10 13:41:39 +08:00
|
|
|
|
},
|
2023-06-14 11:17:45 +08:00
|
|
|
|
chainWebpack: (config) => {
|
|
|
|
|
config.devtool("source-map");
|
|
|
|
|
config.resolve.alias.set("@", resolve("./src"));
|
|
|
|
|
config.output.library("MsFrontend");
|
2022-10-10 13:41:39 +08:00
|
|
|
|
|
2023-06-14 11:17:45 +08:00
|
|
|
|
config.module.rule("svg").exclude.add(resolve("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("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]",
|
|
|
|
|
});
|
2023-05-29 11:52:29 +08:00
|
|
|
|
|
2023-06-14 11:17:45 +08:00
|
|
|
|
if (process.env.NODE_ENV === "analyze") {
|
|
|
|
|
config.plugin("webpack-report").use(BundleAnalyzerPlugin, [
|
|
|
|
|
{
|
|
|
|
|
analyzerMode: "static",
|
|
|
|
|
reportFilename: "./webpack-report.html",
|
|
|
|
|
openAnalyzer: false,
|
|
|
|
|
},
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-06-14 15:19:43 +08:00
|
|
|
|
});
|