1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- const path = require('path')
- const webpack = require('webpack')
- const CopyWebpackPlugin = require('copy-webpack-plugin')
- const CompressionPlugin = require("compression-webpack-plugin")
- let cesiumSource = './node_modules/cesium/Source'
- let cesiumWorkers = '../Build/Cesium/Workers'
- const plugins = []
- module.exports = {
- assetsDir: process.env.VUE_APP_STATIC_URL,
- publicPath: process.env.NODE_ENV === 'production' ? '' : '',
- productionSourceMap: false,
- configureWebpack: config => {
- if (process.env.NODE_ENV === 'production') {
- plugins.push(new CompressionPlugin({
- test: /\.js$|\.html$|.\css/, //匹配文件名
- threshold: 10240, //对超过10k的数据压缩
- deleteOriginalAssets: false //不删除源文件
- }))
- }
- return {
- amd: {
- toUrlUndefined: true
- },
- output: {
- sourcePrefix: ' '
- },
- resolve: {
- alias: {
- 'vue$': 'vue/dist/vue.esm.js',
- '@': path.resolve('src'),
- 'cesium': path.resolve(__dirname, cesiumSource)
- }
- },
- plugins: [
- 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 CopyWebpackPlugin([{ from: path.join(cesiumSource, 'ThirdParty/Workers'), to: 'ThirdParty/Workers' }]),
- new webpack.DefinePlugin({
- CESIUM_BASE_URL: JSON.stringify('./')
- })
- ].concat(plugins),
- module: {
- unknownContextCritical: /^.\/.*$/,
- unknownContextCritical: false // 6
- }
- }
- },
- devServer: {
- proxy: {
- '/data': {
- target: 'http://39.108.123.31'
- },
- '/': {
- target: 'http://39.108.123.31'
- }
- }
- },
- chainWebpack: config => {
-
- }
- }
|