MeterSphere/framework/sdk-parent/frontend/vue.config.js

127 lines
3.2 KiB
JavaScript
Raw Normal View History

const path = require("path");
const { defineConfig } = require("@vue/cli-service");
const BundleAnalyzerPlugin =
require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
2022-10-10 13:41:39 +08:00
function resolve(dir) {
return path.join(__dirname, dir);
}
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: {
webSocketTransport: "sockjs",
2022-10-10 13:41:39 +08:00
},
webSocketServer: "sockjs",
allowedHosts: "all",
2022-10-10 13:41:39 +08:00
proxy: {
["^((?!/login)(?!/document))"]: {
target: "http://localhost:8000",
ws: false,
2022-10-10 13:41:39 +08:00
},
"/websocket": {
target: "http://localhost:8000",
ws: true,
2022-10-10 13:41:39 +08:00
},
},
},
configureWebpack: {
devtool: "cheap-module-source-map",
2022-10-10 13:41:39 +08:00
resolve: {
alias: {
"@": resolve("src"),
},
2022-10-10 13:41:39 +08:00
},
externals: {
qiankun: "qiankun",
vue: "Vue",
"vue-router": "VueRouter",
// 'echarts': 'echarts',
// 'echarts/core': 'echarts', // TODO:外链使用的话需要改造导入及 vue-echarts 的源码
// brace: 'brace', // TODO:暂时未发现能外链的方法本体包未提供cdn 外链形式的包
"element-ui": "ELEMENT",
"vue-shepherd": "VueShepherd",
},
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: 3,
chunks: "all",
},
fortawesome: {
test: /[\\/]@fortawesome[\\/]/,
name: "fortawesome",
priority: 3,
chunks: "all",
},
jspdf: {
test: /[\\/]jspdf[\\/]/,
name: "jspdf",
priority: 3,
chunks: "all",
},
jsencrypt: {
test: /[\\/]jsencrypt[\\/]/,
name: "jsencrypt",
priority: 3,
chunks: "all",
},
pinia: {
test: /[\\/]pinia[\\/]/,
name: "pinia",
priority: 3,
chunks: "all",
},
},
},
},
2022-10-10 13:41:39 +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
config.module.rule("svg").exclude.add(resolve("src/assets/module")).end();
2022-10-10 13:41:39 +08:00
config.module
.rule("icons")
2022-10-10 13:41:39 +08:00
.test(/\.svg$/)
.include.add(resolve("src/assets/module"))
2022-10-10 13:41:39 +08:00
.end()
.use("svg-sprite-loader")
.loader("svg-sprite-loader")
2022-10-10 13:41:39 +08:00
.options({
symbolId: "icon-[name]",
});
if (process.env.NODE_ENV === "analyze") {
config.plugin("webpack-report").use(BundleAnalyzerPlugin, [
{
analyzerMode: "static",
reportFilename: "./webpack-report.html",
openAnalyzer: false,
},
]);
}
},
});