一.初始化vue项目
vue create demo
二.下载cesium
npm i cesium -S
三.配置webpack
npm i *@open-wc/webpack-import-meta-loader* -S
- 自己配置webpack的vue.config.js文件
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
configureWebpack: {
amd: {
toUrlUndefined: true
},
module: {
rules: [
{
test: /\.js$/,
use: {
loader: '@open-wc/webpack-import-meta-loader',
},
},
],
unknownContextCritical: false
},
plugins: [
new CopyWebpackPlugin([
{
from: 'node_modules/cesium/Build/Cesium/Workers',
to: 'cesium/Workers'
}
]),
new CopyWebpackPlugin([
{
from: 'node_modules/cesium/Build/Cesium/ThirdParty',
to: 'cesium/ThirdParty'
}
]),
new CopyWebpackPlugin([
{ from: 'node_modules/cesium/Build/Cesium/Assets', to: 'cesium/Assets' }
]),
new CopyWebpackPlugin([
{
from: 'node_modules/cesium/Build/Cesium/Widgets',
to: 'cesium/Widgets'
}
]),
new webpack.DefinePlugin({
CESIUM_BASE_URL: JSON.stringify('./cesium')
})
],
}
}