129 lines
3.2 KiB
JavaScript
129 lines
3.2 KiB
JavaScript
const { defineConfig } = require('@vue/cli-service')
|
|
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
const cesiumSource = 'node_modules/cesium/Source';
|
|
const cesiumWorkers = '../Build/Cesium/Workers';
|
|
const path = require('path');
|
|
const webpack = require('webpack');
|
|
const cesiumBaseUrl = "cesium"
|
|
module.exports = defineConfig({
|
|
//设置为空打包后不分更目录还是多级目录
|
|
publicPath:'',
|
|
//build编译后存放静态文件的目录
|
|
//assetsDir: "static",
|
|
|
|
// build编译后不生成资源MAP文件
|
|
productionSourceMap: false,
|
|
|
|
//开发服务,build后的生产模式还需nginx代理
|
|
devServer: {
|
|
allowedHosts: 'all',
|
|
open: false, //运行后自动打开浏览器
|
|
port: process.env.VUE_APP_PORT, //挂载端口
|
|
proxy: {
|
|
'/api': {
|
|
target: process.env.VUE_APP_API_BASEURL,
|
|
ws: true,
|
|
changeOrigin:true,
|
|
pathRewrite: {
|
|
'^/api': '/'
|
|
}
|
|
}
|
|
},
|
|
client: {
|
|
overlay: {
|
|
runtimeErrors: false,
|
|
},
|
|
},
|
|
},
|
|
|
|
chainWebpack: config => {
|
|
// 移除 prefetch 插件
|
|
config.plugins.delete('preload');
|
|
config.plugins.delete('prefetch');
|
|
config.resolve.alias.set('vue-i18n', 'vue-i18n/dist/vue-i18n.cjs.js');
|
|
},
|
|
|
|
configureWebpack: {
|
|
//性能提示
|
|
performance: {
|
|
hints: false
|
|
},
|
|
optimization: {
|
|
splitChunks: {
|
|
chunks: "all",
|
|
automaticNameDelimiter: '~',
|
|
name: "scuiChunks",
|
|
maxSize: 4000000, // 限制每个代码块的最大体积,防止生成太大的块
|
|
cacheGroups: {
|
|
//第三方库抽离
|
|
vendor: {
|
|
name: "modules",
|
|
test: /[\\/]node_modules[\\/]/,
|
|
priority: -10
|
|
},
|
|
elicons: {
|
|
name: "elicons",
|
|
test: /[\\/]node_modules[\\/]@element-plus[\\/]icons-vue[\\/]/
|
|
},
|
|
tinymce: {
|
|
name: "tinymce",
|
|
test: /[\\/]node_modules[\\/]tinymce[\\/]/
|
|
},
|
|
echarts: {
|
|
name: "echarts",
|
|
test: /[\\/]node_modules[\\/]echarts[\\/]/
|
|
},
|
|
xgplayer: {
|
|
name: "xgplayer",
|
|
test: /[\\/]node_modules[\\/]xgplayer.*[\\/]/
|
|
},
|
|
codemirror: {
|
|
name: "codemirror",
|
|
test: /[\\/]node_modules[\\/]codemirror[\\/]/
|
|
},
|
|
babylonjs: {
|
|
name: "babylonjs",
|
|
test: /[\\/]node_modules[\\/]babylon[\\/]/
|
|
},
|
|
cesium: {
|
|
name: "cesium",
|
|
test: /[\\/]node_modules[\\/]cesium[\\/]/
|
|
}
|
|
}
|
|
}
|
|
},
|
|
resolve:{
|
|
fallback:{
|
|
fs:false,
|
|
crypto: require.resolve("crypto-browserify"),
|
|
stream: false,
|
|
}
|
|
},
|
|
plugins: [
|
|
new NodePolyfillPlugin(),
|
|
new CopyWebpackPlugin({
|
|
patterns: [
|
|
{ from: path.join(cesiumSource, cesiumWorkers), to: `${cesiumBaseUrl}/Workers`, },
|
|
{ from: path.join(cesiumSource, "ThirdParty"), to: `${cesiumBaseUrl}/ThirdParty`, },
|
|
{ from: path.join(cesiumSource, "Assets"), to: `${cesiumBaseUrl}/Assets`, },
|
|
{ from: path.join(cesiumSource, "Widgets"), to: `${cesiumBaseUrl}/Widgets`, },
|
|
],
|
|
}),
|
|
new webpack.DefinePlugin({
|
|
// Define relative base path in cesium for loading assets
|
|
CESIUM_BASE_URL: JSON.stringify(cesiumBaseUrl),
|
|
}),
|
|
],
|
|
externals:{
|
|
'./cptable':'var cptable'
|
|
},
|
|
},
|
|
pluginOptions: {
|
|
'style-resources-loader': {
|
|
preProcessor: 'sass',
|
|
patterns: []
|
|
}
|
|
},
|
|
})
|