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: false, // 是否开启eslint devServer: { https: true, open: true, port: 8091, overlay: { warnings: false, errors: true, }, proxy: { '/yapi': { // target: 'http://39.101.177.49:5013/', // 远程服务器-皞哥 // target: 'http://127.0.0.1:18201/prod-api/', // 贵州现场 target: 'https://11.100.46.218:8080/prod-api/', // 贵都匀现场 // target: 'http://11.100.46.220:8080/prod-api/', // 贵州现场 // target: 'http://192.168.1.10:8080/prod-api/', // 贵州现场 // target: 'http://192.168.18.219:22102/prod-api/', // 都匀转发 // target: 'http://192.168.18.219:22100/prod-api/', // 托克托转发 // target: 'http://192.168.195.134:8080/prod-api/', // 贵州现场 // target: 'http://172.168.0.62:8080/prod-api/', // 托克托现场 // target: 'http://192.168.195.136:8080/prod-api/', // 托克托本地 // target: 'http://192.168.1.10:8080/prod-api/', // 贵州现场 // target: 'http://11.100.46.220:8080/prod-api/', // 贵州现场 // target: "http://localhost:5002", // 远程服务器-赵哥 // target: "http://127.0.0.1:18914/yapi/", changeOrigin: true, pathRewrite: { '^/yapi': '/', }, }, '/model': { // target: 'http://39.101.177.49:5013/model/', //模型服务器 // target: 'http://127.0.0.1:18202/model/', //贵州现场 // target: 'http://11.100.46.220:8081/model/', //都匀现场 target: 'https://11.100.46.218:8081/model/', //都匀现场 // target: "http://192.168.70.11:8081/model/", // 静海现场 // target: "http://localhost:8000/model/", // 济北综合站现场服务器 // target: 'http://11.100.46.220:8081/model/', //贵阳模型服务器 // target: 'http://192.168.1.10:8081/model/', //贵阳模型服务器 // target: 'http://192.168.18.219:22101/model/', //托克托模型服务器转发 // target: 'http://192.168.18.219:22103/model/', //都匀模型服务器转发 // target: 'http://192.168.195.134:8081/model/', //模型服务器 // target: 'http://172.168.0.62:8081/model/', //托克托模型现场服务器 // target: 'http://192.168.195.136:8081/model/', //托克托模型服务器 changeOrigin: true, pathRewrite: { '^/model': '/', }, }, }, }, 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' }]), new webpack.ProvidePlugin({ process: 'process/browser', Buffer: ['buffer', 'Buffer'], }), ] } 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' }]), new webpack.ProvidePlugin({ process: 'process/browser', Buffer: ['buffer', 'Buffer'], }), ] } 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, }, }, }, ], }, { test: /.js$/, include: path.resolve(__dirname, 'node_modules/cesium/Source'), use: { loader: require.resolve('@open-wc/webpack-import-meta-loader'), }, }, ], }, 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: { '@': path.resolve('src'), }, }, node: { fs: 'empty', Buffer: false, http: 'empty', https: 'empty', zlib: 'empty', }, plugins: plugins, } }, }