Usage with webpack
It is possible to use Whitestorm.js with webpack. To do this you should add some lines in your webpack config:
Usage with physics
// Webpack config file
// ...
plugins: [
new webpack.NormalModuleReplacementPlugin(
/inline\-worker/,
'webworkify-webpack'
)
// ...
],
// ...
Add new webpack.NormalModuleReplacementPlugin(/inline\-worker/, 'webworkify-webpack')
to plugins section in webpack config.
Explanation
Currently we use InlineWorker to maintain Web Workers in node environment. Same thing with InlineWorker is possible in webpack too, but dependencies wouldn't be accessible from
worker.js
file. To solve this problem we use special plugin: webworkify-webpack. This plugin is already included to whitestorm'spackage.json
so there is no need to install it again.
Without physics (light version)
// Webpack config file
// ...
externals: {
'../physics/index.js': 'var false',
'./physics/index.js': 'var false'
},
// ..
To use whitestorm.js without including Physi.js you should add it's paths as externals in webpack config (look to the right for code). It will remove all Physi.js files and Ammo.js and will let you use a more lightweight bundle.
Source code on GitHub
You may also check implementation of Whitestorm.js with webpack at [GitHub] WhitestormJS/test-whitestorm-webpack for more details. You will find also notes about compressing bundle there.
- webpack.config.js - this one is configuration for bundle with physics support.
- webpack.light.config.js - this one is configuration for bundle without physics support and ammo.js included.
Updated less than a minute ago