UNPKG

gisthreemap

Version:

基于webGL的三维api

72 lines (71 loc) 2.67 kB
// The path to the CesiumJS source code const path = require('path'); const webpack = require('webpack'); // 头部引入 const NodePolyfillPlugin = require('node-polyfill-webpack-plugin') const HtmlWebpackPlugin = require('html-webpack-plugin'); const CopyWebpackPlugin = require("copy-webpack-plugin"); const cesiumSourcePath = "node_modules/mars3d-cesium/Build/Cesium/"; // cesium库安装目录 const cesiumRunPath = "./mars3d-cesium/"; // cesium运行时路径 module.exports = { context: __dirname, entry: { app: './src/index.js' }, output: { filename: 'app.js', path: path.resolve(__dirname, 'dist'), sourcePrefix: '' }, amd: { // Enable webpack-friendly use of require in Cesium toUrlUndefined: true }, resolve: { alias: { "elasticsearch": false } }, module: { unknownContextCritical: false, rules: [{ test: /\.css$/, use: ['style-loader', 'css-loader'] }, { test: /\.(png|gif|jpg|jpeg|svg|xml|json)$/, use: ['url-loader'] }, { test: /\.(woff|woff2|eot|ttf|otf)$/, use: [ { loader: 'file-loader', options: { outputPath: 'assets/fonts' } }, ] }] }, plugins: [ new NodePolyfillPlugin(), new HtmlWebpackPlugin({ template: path.resolve(__dirname, 'public/index.html'), // 使用的HTML模板 filename: 'index.html', // 打包生成到的HTML文件名 }), // CESIUM_BASE_URL是标识cesium资源所在的主目录,其内部资源加载、多线程等处理时需要用到 new webpack.DefinePlugin({ CESIUM_BASE_URL: JSON.stringify(cesiumRunPath), }), // Cesium相关资源目录需要拷贝到系统目录下面(部分CopyWebpackPlugin版本的语法可能没有patterns) new CopyWebpackPlugin({ patterns: [ { from: path.join(cesiumSourcePath, 'Workers'), to: path.join(cesiumRunPath, 'Workers') }, { from: path.join(cesiumSourcePath, 'Assets'), to: path.join(cesiumRunPath, 'Assets') }, { from: path.join(cesiumSourcePath, 'ThirdParty'), to: path.join(cesiumRunPath, 'ThirdParty') }, { from: path.join(cesiumSourcePath, 'Widgets'), to: path.join(cesiumRunPath, 'Widgets') } ] }) ], mode: 'development', devtool: 'eval' }