1 Star 0 Fork 0

ttttaeyang/cesium-vue

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
vue.config.js 3.10 KB
一键复制 编辑 原始数据 按行查看 历史
ShareQiu 提交于 2020-04-04 12:18 . 采用ES6 模块加载方式
const webpack = require('webpack')
const path = require('path')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const cesiumSource = 'node_modules/cesium/Build/Cesium'
module.exports = {
publicPath: './',
assetsDir: './static',
productionSourceMap: false,
lintOnSave: true, // 是否开启eslint
devServer: {
open: true
},
configureWebpack: (config) => {
let plugins = []
if (process.env.NODE_ENV === 'production') {
plugins = [
new webpack.DefinePlugin({
CESIUM_BASE_URL: JSON.stringify('static')
}),
new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'Workers'), to: 'static/Workers' }]),
new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'Assets'), to: 'static/Assets' }]),
new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'ThirdParty'), to: 'static/ThirdParty' }]),
new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'Widgets'), to: 'static/Widgets' }])
]
} else {
plugins = [
new webpack.DefinePlugin({
CESIUM_BASE_URL: JSON.stringify('')
}),
new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'Workers'), to: 'Workers' }]),
new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'Assets'), to: 'Assets' }]),
new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'ThirdParty'), to: 'ThirdParty' }]),
new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'Widgets'), to: 'Widgets' }])
]
}
return {
module: {
unknownContextCritical: false,
rules: [
{
test: /\.js$/,
enforce: 'pre',
include: path.resolve(__dirname, 'node_modules/cesium/Source'),
sideEffects: false,
use: [
{
loader: 'strip-pragma-loader',
options: {
pragmas: {
debug: false
}
}
}
]
}
]
},
optimization: {
usedExports: true,
splitChunks: {
maxInitialRequests: Infinity,
minSize: 0,
maxSize: 250000,
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
priority: -10,
chunks: 'all',
name(module) {
const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1]
return `npm.${packageName.replace('@', '')}`
}
},
commons: {
name: 'Cesium',
test: /[\\/]node_modules[\\/]cesium/,
priority: 10,
chunks: 'all'
}
}
}
},
output: {
sourcePrefix: ' '
},
amd: {
toUrlUndefined: true
},
resolve: {
alias: {
vue$: 'vue/dist/vue.esm.js',
'@': path.resolve('src')
}
},
node: {
fs: 'empty',
Buffer: false,
http: 'empty',
https: 'empty',
zlib: 'empty'
},
plugins: plugins
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/tttaeyang/cesium-vue.git
git@gitee.com:tttaeyang/cesium-vue.git
tttaeyang
cesium-vue
cesium-vue
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385