Permalink
Browse files

Add scripts to build a Cesium bundle with DllPlugin

  • Loading branch information...
markerikson committed Mar 4, 2017
1 parent 5a27fed commit b55dbd56c7093a28c54c4294442f67179e895839
Showing with 77 additions and 1 deletion.
  1. +2 −1 .gitignore
  2. +1 −0 package.json
  3. +11 −0 scripts/buildCesiumDLL.js
  4. +63 −0 scripts/webpackCompile.js
View
@@ -8,7 +8,8 @@
# production
/build
/public/cesium/
distdll/
# misc
.DS_Store
View
@@ -55,6 +55,7 @@
"scripts": {
"start": "node scripts/start.js",
"build": "node scripts/build.js",
"build:dll:cesium": "node ./scripts/buildCesiumDLL.js",
"test": "node scripts/test.js --env=jsdom"
},
"jest": {
View
@@ -0,0 +1,11 @@
const path = require("path");
const webpack = require("webpack");
const compile = require("./webpackCompile");
const cesiumConfig = require('../config/webpack.cesium.dll.config.js');
compile("cesium", cesiumConfig)
.then( ({stats}) => {
});
View
@@ -0,0 +1,63 @@
const webpack = require("webpack");
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const chalk = require("chalk");
function compile (name, webpackConfig, options = {}) {
if(!webpackConfig.plugins) {
webpackConfig.plugins = [];
}
const {showProgress = true} = options;
const {logStats = true} = options;
if(showProgress) {
webpackConfig.plugins.push(new ProgressBarPlugin({
format: ' build [:bar] ' + chalk.green.bold(':percent') + ' (:elapsed seconds) (:msg)',
clear: false
}));
}
const compiler = webpack(webpackConfig)
return new Promise((resolve, reject) => {
console.log(`Compiling: ${name}`);
compiler.run((err, stats) => {
if (err) return reject(err);
if (stats.hasErrors()) {
return reject(new Error(stats.toString({
errorDetails: true,
warnings: true
})));
}
if(logStats) {
stats.compilation.children = stats.compilation.children.filter(child => {
if(child.name.includes("extract-text")) {
const assetNames = Object.keys(child.assets);
return assetNames.length > 0;
}
return true;
});
const statsString = stats.toString({
chunks: false, // Makes the build much quieter
colors: true,
warnings: true
});
console.log(statsString);
}
resolve({ stats});
});
})
}
module.exports = compile;

0 comments on commit b55dbd5

Please sign in to comment.