diff --git a/README.md b/README.md index 17af6d0..3b4c7d7 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,9 @@ npm install sim-ecs - [Adding Entities](#adding-entities) - [Working with States](#working-with-states-optional) - [Update loop](#Update-loop) -- [Using Prefabs](#using-prefabs) +- [Saving and using Prefabs](#saving-and-using-prefabs) - [Save and Load a World](#save-and-load-a-world) +- [Building for Production](#building-for-production) - [Comparison with other TS ECS libs](#comparison-with-other-ts-ecs-libs) - [Features](#features) - [Performance](#performance) @@ -275,6 +276,13 @@ At this point, the data can also be manipulated, for example updating timestamps Usually, though, registering the Components is enough for sim-ecs to correctly handle deserialization. +## Building for Production + +When building for production, it is important to keep class names. +Some minimizers need to be adjusted. For example WebPack (using Terser) needs to pass this as configuration. +The Pong example uses WebPack and demonstrates how to set up WebPack for proper production usage (in `make.js`). + + ## Comparison with other TS ECS libs In an attempt to make sim-ecs best in class, it is important to compare it to other ECS libraries, diff --git a/examples/pong/make.js b/examples/pong/make.js index 081b3d3..731280f 100644 --- a/examples/pong/make.js +++ b/examples/pong/make.js @@ -3,6 +3,7 @@ const webpack = require('webpack'); const fs = require('fs-extra'); const path = require('path'); const ProgressBarPlugin = require('progress-bar-webpack-plugin'); +const TerserPlugin = require("terser-webpack-plugin"); // arg handling const args = arg({ @@ -51,6 +52,14 @@ const log = (...strs) => console.log.apply(console.log, ['[make]'].concat(strs)) path: outDir, filename: 'bundle.js' }, + optimization: { + minimize: true, + minimizer: [new TerserPlugin({ + terserOptions: { + keep_classnames: true, + }, + })], + }, resolve: { extensions: ['.js', '.ts'], modules: ['node_modules'], diff --git a/examples/pong/package.json b/examples/pong/package.json index 0c049a3..bbc30c1 100644 --- a/examples/pong/package.json +++ b/examples/pong/package.json @@ -20,6 +20,7 @@ "sass-loader": "^11.0.1", "sim-ecs": "file://../..", "style-loader": "^2.0.0", + "terser-webpack-plugin": "^5.1.2", "to-string-loader": "^1.1.6", "ts-loader": "^8.1.0", "tslib": "latest",