const CopyWebpackPlugin = require('copy-webpack-plugin')
const webpack = require('webpack')
const path = require('path')
CesiumJS源代码的路径
const cesiumSource = 'node_modules/cesium/Source'
const cesiumWorkers = '../Build/Cesium/Workers'
const CopywebpackPlugin = require('copy-webpack-plugin');
module.exports = {
// productionSourceMap:false
publicPath:'./',//输出的根路径 默认是/ 如果你的网站是app.com/vue 这更改此配置项
outputDir:'dist',//构建输出目录
// assetsDir:'assets',//静态资源目录(js,css,img,fonts)
productionSourceMap: true,
lintOnSave:false,//是否开启eslint保存检测,有效值: true || false || 'error'
devServer:{
open:false,//是否自动弹出
//host:'localhost',
//port:8088,//端口
https:false,
hotOnly:false,//热更新
proxy : {}
},
/* 添加以下代码是为解决webpack如何编译CesiumJS的一些怪癖 */
configureWebpack: {
/* 覆盖webpack默认值,以便\t在每行之前添加制表符。CesiumJS有一些多行字符串,因此我们需要使用空前缀覆盖此默认值''。 */
output: { sourcePrefix: ' ' },
/* 告诉CesiumJS,AMD webpack用于评估require语句的版本不符合标准toUrl函数。 */
amd: { toUrlUndefined: true },
// 解析节点模块使用的fs,解决了fs模块的某些第三方用法,该模块的目标是在节点环境而不是浏览器中使用
node: { fs: 'empty' },
//添加cesium 别名别名,以便我们可以在我们的应用代码中引用它
// resolve: { alias: { cesium: path.resolve(__dirname, cesiumSource)} },
resolve: {
alias: {
cesium: path.resolve(__dirname, './node_modules/cesium/Source'),
} ,
},
plugins: [
// Copy Cesium Assets, Widgets, and Workers to a static directory
new CopywebpackPlugin([ { from: path.join('node_modules/cesium/Build/Cesium', 'Workers'), to: 'Workers' } ]),
new CopywebpackPlugin([ { from: path.join('node_modules/cesium/Source', 'Assets'), to: 'Assets' } ]),
new CopywebpackPlugin([ { from: path.join('node_modules/cesium/Source', 'Widgets'), to: 'Widgets' } ]),
new CopywebpackPlugin([ { from: path.join('node_modules/cesium/Source', 'ThirdParty'), to: 'ThirdParty' } ]),
// Define relative base path in cesium for loading assets
new webpack.DefinePlugin({ CESIUM_BASE_URL: JSON.stringify('') }),
new webpack.ProvidePlugin({
$:"jquery",
jQuery:"jquery",
"windows.jQuery":"jquery"
})
],
module: {
rules:[
{
test:/\.js\.map$/,
use:{
loader:' file-loader'
}
}
],
unknownContextCritical: /^.\/.*$/,
unknownContextCritical: false
}
}
}
cesium插件配置文件
最新推荐文章于 2025-03-17 12:31:02 发布