2022-10-10 13:41:39 +08:00
|
|
|
|
const path = require('path');
|
2022-11-21 12:47:19 +08:00
|
|
|
|
const { name } = require('./package');
|
2023-05-29 11:52:29 +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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
2022-10-10 18:35:38 +08:00
|
|
|
|
productionSourceMap: false,
|
2022-10-10 13:41:39 +08:00
|
|
|
|
devServer: {
|
|
|
|
|
port: 4004,
|
|
|
|
|
client: {
|
|
|
|
|
webSocketTransport: 'sockjs',
|
|
|
|
|
},
|
2022-10-13 12:39:31 +08:00
|
|
|
|
allowedHosts: 'all',
|
2022-10-10 13:41:39 +08:00
|
|
|
|
webSocketServer: 'sockjs',
|
|
|
|
|
proxy: {
|
|
|
|
|
['^((?!/login)(?!/document))']: {
|
|
|
|
|
target: 'http://localhost:8004',
|
2022-11-21 12:47:19 +08:00
|
|
|
|
ws: false,
|
2022-10-10 13:41:39 +08:00
|
|
|
|
},
|
|
|
|
|
'/websocket': {
|
|
|
|
|
target: 'http://localhost:8004',
|
2022-11-21 12:47:19 +08:00
|
|
|
|
ws: true,
|
2022-10-10 13:41:39 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
// 跨域
|
|
|
|
|
headers: {
|
|
|
|
|
'Access-Control-Allow-Origin': '*',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
pages: {
|
|
|
|
|
index: {
|
2022-11-21 12:47:19 +08:00
|
|
|
|
entry: 'src/main.js',
|
|
|
|
|
template: 'public/index.html',
|
|
|
|
|
filename: 'index.html',
|
2022-10-10 13:41:39 +08:00
|
|
|
|
},
|
|
|
|
|
shareApiReport: {
|
2022-11-21 12:47:19 +08:00
|
|
|
|
entry: 'src/template/report/share/share-api-report.js',
|
|
|
|
|
template: 'src/template/report/share/share-api-report.html',
|
|
|
|
|
filename: 'share-api-report.html',
|
2022-10-10 13:41:39 +08:00
|
|
|
|
},
|
|
|
|
|
shareDocument: {
|
2022-11-21 12:47:19 +08:00
|
|
|
|
entry: 'src/template/document/share/share-document.js',
|
|
|
|
|
template: 'src/template/document/share/share-document.html',
|
|
|
|
|
filename: 'share-document.html',
|
2022-10-10 13:41:39 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
configureWebpack: {
|
2022-10-10 18:35:38 +08:00
|
|
|
|
devtool: 'cheap-module-source-map',
|
2022-10-10 13:41:39 +08:00
|
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
2022-11-21 12:47:19 +08:00
|
|
|
|
'@': resolve('src'),
|
2023-05-29 11:52:29 +08:00
|
|
|
|
'mockjs': resolve('node_modules/mockjs'),
|
|
|
|
|
'vue-i18n': resolve('node_modules/vue-i18n'),
|
|
|
|
|
'jsondiffpatch': resolve('node_modules/jsondiffpatch'),
|
2022-11-21 12:47:19 +08:00
|
|
|
|
},
|
2022-10-10 13:41:39 +08:00
|
|
|
|
},
|
|
|
|
|
output: {
|
|
|
|
|
// 把子应用打包成 umd 库格式(必须)
|
|
|
|
|
library: `${name}-[name]`,
|
|
|
|
|
libraryTarget: 'umd',
|
|
|
|
|
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
|
|
|
|
externals: {
|
|
|
|
|
vue: 'Vue',
|
|
|
|
|
'vue-router': 'VueRouter',
|
|
|
|
|
// 'echarts': 'echarts',
|
|
|
|
|
// 'echarts/core': 'echarts', // TODO:外链使用的话需要改造导入及 vue-echarts 的源码
|
|
|
|
|
// brace: 'brace', // TODO:暂时未发现能外链的方法,本体包未提供cdn 外链形式的包
|
|
|
|
|
'element-ui': 'ELEMENT',
|
|
|
|
|
'mavon-editor': 'MavonEditor',
|
|
|
|
|
'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: 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',
|
|
|
|
|
},
|
|
|
|
|
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: {
|
|
|
|
|
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',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
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`,
|
2022-11-21 12:47:19 +08:00
|
|
|
|
chunkFilename: `css/${name}-[name].[contenthash:8].css`,
|
2022-10-10 13:41:39 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
2022-11-21 12:47:19 +08:00
|
|
|
|
chainWebpack: (config) => {
|
2022-11-21 15:07:23 +08:00
|
|
|
|
config.module.rule('svg').exclude.add(resolve('../../framework/sdk-parent/frontend/src/assets/module')).end();
|
2022-10-10 13:41:39 +08:00
|
|
|
|
config.module
|
|
|
|
|
.rule('icons')
|
|
|
|
|
.test(/\.svg$/)
|
2022-11-21 15:07:23 +08:00
|
|
|
|
.include.add(resolve('../../framework/sdk-parent/frontend/src/assets/module'))
|
2022-10-10 13:41:39 +08:00
|
|
|
|
.end()
|
|
|
|
|
.use('svg-sprite-loader')
|
|
|
|
|
.loader('svg-sprite-loader')
|
|
|
|
|
.options({
|
2022-11-21 12:47:19 +08:00
|
|
|
|
symbolId: 'icon-[name]',
|
|
|
|
|
});
|
2023-05-29 11:52:29 +08:00
|
|
|
|
|
|
|
|
|
if (process.env.NODE_ENV === 'analyze') {
|
|
|
|
|
config.plugin('webpack-report').use(BundleAnalyzerPlugin, [
|
|
|
|
|
{
|
|
|
|
|
analyzerMode: 'static',
|
|
|
|
|
reportFilename: './webpack-report.html',
|
|
|
|
|
openAnalyzer: false,
|
|
|
|
|
},
|
|
|
|
|
]);
|
|
|
|
|
}
|
2022-11-21 12:47:19 +08:00
|
|
|
|
},
|
2022-10-10 13:41:39 +08:00
|
|
|
|
};
|