vue +cesium 加载天地图

 npm install cesium --save

webpack.base.conf.js文件

const cesiumSource = '../node_modules/cesium/Source'
output: {
    path: config.build.assetsRoot,
    filename: '[name].js',
    publicPath: process.env.NODE_ENV === 'production' ?
      config.build.assetsPublicPath : config.dev.assetsPublicPath,
    // cesium
    sourcePrefix: ' '
  },
 // cesium
  amd: {
    toUrlUndefined: true
  },
  resolve: {
    extensions: ['.js', '.vue', '.json'],
    alias: {
      'vue$': 'vue/dist/vue.esm.js',
      '@': resolve('src'),
      // cesium
      'cesium': path.resolve(__dirname, cesiumSource)
    },
  },

vue +cesium 加载天地图_第1张图片 

unknownContextCritical: false,

 webpack.dev.conf.js 文件

// cesium
//定义 Cesium 源码路径(注意这里的 node_modules 与webpack.base.conf.js的不同,前面没有 …/ ),
const cesiumSource = 'node_modules/cesium/Source'
//定义 Cesium Workers 路径:
const cesiumWorkers = '../Build/Cesium/Workers';
plugins: [
    //cesium
    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 webpack.DefinePlugin({
      CESIUM_BASE_URL: JSON.stringify('')
    })
  ]

 webpack.prod.conf.js 文件

// cesium
//定义 Cesium 源码路径(注意这里的 node_modules 与webpack.base.conf.js的不同,前面没有…/)
const cesiumSource = '../node_modules/cesium/Source'
//定义 Cesium Workers 路径
const cesiumWorkers = '../Build/Cesium/Workers'

plugins: [
    // cesium
    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 webpack.DefinePlugin({
      CESIUM_BASE_URL: JSON.stringify('. /')
    })
  ]

config/index.js文件

vue +cesium 加载天地图_第2张图片

cesiumViewer.vue




 

你可能感兴趣的:(cesium)