microwave-project-unite/vue.config.js

117 lines
4.2 KiB
JavaScript
Raw Normal View History

2023-01-09 01:55:54 +00:00
// 拷贝文件插件
const CopyWebpackPlugin = require("copy-webpack-plugin");
const webpack = require("webpack");
const path = require("path");
let cesiumSource = "./node_modules/cesium/Source";
let cesiumWorkers = "../Build/Cesium/Workers";
module.exports = {
// 基本路径
publicPath: "./",
// 输出文件目录
outputDir: "dist",
assetsDir: "static",
indexPath: "index.html",
filenameHashing: true,
productionSourceMap: false,
lintOnSave: false, // 在保存代码的时候开启eslint代码检查机制
devServer: {
// 实时保存,编译的配置段
port: 8085, // http服务的端口号码设定
open: false,
proxy: {
[process.env.VUE_APP_BASE_API]: {
2024-07-04 01:38:01 +00:00
target: "https://124.16.188.131:28030",
2023-01-09 01:55:54 +00:00
changeOrigin: true,
pathRewrite: {
["^" + process.env.VUE_APP_BASE_API]: ""
}
},
2023-01-11 01:15:17 +00:00
[process.env.VUE_APP_MICROWAVE_API]: {
2023-08-01 08:18:31 +00:00
target: "http://124.16.188.131:18086/macApi",
2023-01-11 01:15:17 +00:00
changeOrigin: true,
pathRewrite: {
["^" + process.env.VUE_APP_MICROWAVE_API]: ""
}
},
2023-01-09 01:55:54 +00:00
[process.env.VUE_APP_REALITY_API]: {
2024-07-04 01:38:01 +00:00
target: "https://124.16.188.131:28092/microwave",
// target: "http://192.168.1.79:18092/microwave",
2023-01-09 01:55:54 +00:00
changeOrigin: true,
pathRewrite: {
["^" + process.env.VUE_APP_REALITY_API]: ""
}
},
[process.env.VUE_APP_FILE_API]: {
2024-07-04 01:38:01 +00:00
target: "https://124.16.188.131:28093/file",
// target: "http://192.168.1.79:18093/file",
2023-01-09 01:55:54 +00:00
changeOrigin: true,
pathRewrite: {
["^" + process.env.VUE_APP_FILE_API]: ""
}
}
}
},
configureWebpack: {
output: {
sourcePrefix: " "
},
amd: {
toUrlUndefined: true
},
resolve: {
alias: {
vue$: "vue/dist/vue.esm.js",
//可以对同一个地址起2个不同的别名
"@": path.resolve("src"),
src: path.resolve("src"),
cesium: path.resolve(__dirname, cesiumSource)
}
},
plugins: [
new CopyWebpackPlugin([
{ from: path.join(cesiumSource, cesiumWorkers), to: "static/Workers" }
]),
new CopyWebpackPlugin([
{ from: path.join(cesiumSource, "Assets"), to: "static/Assets" }
]),
new CopyWebpackPlugin([
{ from: path.join(cesiumSource, "Widgets"), to: "static/Widgets" }
]),
new CopyWebpackPlugin([
{
from: path.join(cesiumSource, "ThirdParty/Workers"),
to: "static/ThirdParty/Workers"
}
]),
new webpack.DefinePlugin({
CESIUM_BASE_URL: JSON.stringify("./static")
})
// new CopyWebpackPlugin([ { from: path.join(cesiumSource, cesiumWorkers), to: 'Workers'}]),
// new CopyWebpackPlugin([ { from: path.join(cesiumSource, 'Assets'), to: 'Assets'}]),
// new CopyWebpackPlugin([ { from: path.join(cesiumSource, 'Widgets'), to: 'Widgets'}]),
// new CopyWebpackPlugin([ { from: path.join(cesiumSource, 'ThirdParty/Workers'), to: 'ThirdParty/Workers'}]),
// new webpack.DefinePlugin({
// //定义 Cesium 从哪里加载资源,如果使用默认的''
// //却变成了绝对路径了,所以这里使用'./',使用相对路径
// CESIUM_BASE_URL: JSON.stringify('./')
// })
],
optimization: {
splitChunks: {
cacheGroups: {
commons: {
name: "Cesium",
test: /[\\/]node_modules[\\/]cesium/,
chunks: "all"
}
}
}
},
module: {
// unknownContextCritical: /^.\/.*$/,
unknownContextCritical: false
}
}
};