Skip to content
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.

Commit

Permalink
Welcome Cesium 3d visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
Renaud009 committed Aug 21, 2018
1 parent 7308236 commit 73a8a51
Show file tree
Hide file tree
Showing 4 changed files with 449 additions and 8 deletions.
33 changes: 31 additions & 2 deletions build/webpack.config.js
@@ -1,13 +1,17 @@
import webpack from 'webpack';
import cssnano from 'cssnano';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import CopyWebpackPlugin from 'copy-webpack-plugin'
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import config from '../config';
import _debug from 'debug';
import path from 'path';

const debug = _debug('app:webpack:config');
const paths = config.utils_paths;
const {__DEV__, __PROD__, __TEST__} = config.globals;
const cesiumSource = paths.base() + '/node_modules/cesium/Source';
const cesiumWorkers = '../Build/Cesium/Workers';

debug('Create configuration.');
const webpackConfig = {
Expand All @@ -16,7 +20,11 @@ const webpackConfig = {
devtool: config.compiler_devtool,
resolve: {
root: paths.client(),
extensions: ['', '.js', '.jsx', '.json']
extensions: ['', '.js', '.jsx', '.json'],
alias: {
// Cesium module name
cesium: cesiumSource
}
},
module: {}
};
Expand All @@ -42,9 +50,15 @@ webpackConfig.entry = {
webpackConfig.output = {
filename: `[name].[${config.compiler_hash_type}].js`,
path: paths.dist(),
sourcePrefix: '', // Needed by cesium
publicPath: config.compiler_public_path
};

webpackConfig.amd = {
// Enable webpack-friendly use of require in cesium
toUrlUndefined: true
};

// ------------------------------------
// Plugins
// ------------------------------------
Expand All @@ -59,7 +73,22 @@ webpackConfig.plugins = [
minify: {
collapseWhitespace: true
}
})
}),
// Cesium Assets Copy
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 webpack.DefinePlugin({
// Define relative base path in cesium for loading assets
CESIUM_BASE_URL: JSON.stringify('')
}),
// Split cesium into a seperate bundle
/*new webpack.optimize.CommonsChunkPlugin({
name: 'cesium',
minChunks: function (module) {
return module.context && module.context.indexOf('cesium') !== -1;
}
})*/
];

if (__DEV__) {
Expand Down

0 comments on commit 73a8a51

Please sign in to comment.