安装 copy-webpack-plugin
这里需要注意,有版本的要求,这里用的版本是 5.1.2 ,不同版本插件的配置方式不同
npm install copy-webpack-plugin@5.1.2
or
yarn add copy-webpack-plugin@5.1.2
vue.config.js 的配置方式
const CopyWebpackPlugin = require('copy-webpack-plugin')
const webpack = require('webpack')
const path = require('path')
let cesiumSource = './node_modules/cesium/Source'
let cesiumDir = '../Build/Cesium'
module.exports = {
configureWebpack: {
output: {
sourcePrefix: ' '
},
amd: {
toUrlUndefined: true
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': path.resolve('src'),
}
},
plugins: [
new CopyWebpackPlugin([
{ from: path.join(cesiumSource, `${cesiumDir}/Workers`), to: 'Cesium/Workers' },
{ from: path.join(cesiumSource, `${cesiumDir}/Assets`), to: 'Cesium/Assets' },
{ from: path.join(cesiumSource, `${cesiumDir}/Assets`), to: 'Cesium/Assets' },
{ from: path.join(cesiumSource, `${cesiumDir}/Widgets`), to: 'Cesium/Widgets' },
{ from: path.join(cesiumSource, `${cesiumDir}/ThirdParty`), to: 'Cesium/ThirdParty' }
]),
new webpack.DefinePlugin({
CESIUM_BASE_URL: JSON.stringify('./')
})
],
module: {
unknownContextCritical: /^.\/.*$/,
unknownContextCritical: false
}
}
}
nuxt.config.js 配置文件
|