From 209e35afd8aac88dde09b0865ed3b0ee5bdb809a Mon Sep 17 00:00:00 2001
From: David Sehnal <david.sehnal@gmail.com>
Date: Wed, 20 Feb 2019 16:56:47 +0100
Subject: [PATCH] animation tweak, make npm build-webpack a production build

---
 package.json                               | 2 +-
 src/mol-plugin/behavior/static/state.ts    | 2 +-
 src/mol-plugin/command.ts                  | 2 +-
 src/mol-plugin/state/animation/built-in.ts | 2 +-
 webpack.config.js                          | 2 ++
 5 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/package.json b/package.json
index 58063c0f5..0a94d9001 100644
--- a/package.json
+++ b/package.json
@@ -18,7 +18,7 @@
     "watch": "concurrently --kill-others \"npm:watch-ts\" \"npm:watch-extra\" \"npm:watch-webpack\"",
     "watch-ts": "tsc -watch",
     "watch-extra": "cpx \"src/**/*.{vert,frag,glsl,scss,woff,woff2,ttf,otf,eot,svg,html,gql}\" build/src/ --watch",
-    "build-webpack": "webpack --mode development",
+    "build-webpack": "webpack --mode production",
     "watch-webpack": "webpack -w --mode development",
     "model-server": "node build/src/servers/model/server.js",
     "model-server-watch": "nodemon --watch build/src build/src/servers/model/server.js"
diff --git a/src/mol-plugin/behavior/static/state.ts b/src/mol-plugin/behavior/static/state.ts
index 2e53ede8c..74424b9d6 100644
--- a/src/mol-plugin/behavior/static/state.ts
+++ b/src/mol-plugin/behavior/static/state.ts
@@ -51,7 +51,7 @@ export function SetCurrentObject(ctx: PluginContext) {
 }
 
 export function Update(ctx: PluginContext) {
-    PluginCommands.State.Update.subscribe(ctx, ({ state, tree }) => ctx.runTask(state.updateTree(tree)));
+    PluginCommands.State.Update.subscribe(ctx, ({ state, tree, doNotLogTiming }) => ctx.runTask(state.updateTree(tree, doNotLogTiming)));
 }
 
 export function ApplyAction(ctx: PluginContext) {
diff --git a/src/mol-plugin/command.ts b/src/mol-plugin/command.ts
index d17b98dae..5e99045b2 100644
--- a/src/mol-plugin/command.ts
+++ b/src/mol-plugin/command.ts
@@ -17,7 +17,7 @@ export const PluginCommands = {
     State: {
         SetCurrentObject: PluginCommand<{ state: State, ref: Transform.Ref }>(),
         ApplyAction: PluginCommand<{ state: State, action: StateAction.Instance, ref?: Transform.Ref }>(),
-        Update: PluginCommand<{ state: State, tree: State.Tree | State.Builder }>(),
+        Update: PluginCommand<{ state: State, tree: State.Tree | State.Builder, doNotLogTiming?: boolean }>(),
 
         RemoveObject: PluginCommand<{ state: State, ref: Transform.Ref }>(),
 
diff --git a/src/mol-plugin/state/animation/built-in.ts b/src/mol-plugin/state/animation/built-in.ts
index 86593b3f4..d8f3b054f 100644
--- a/src/mol-plugin/state/animation/built-in.ts
+++ b/src/mol-plugin/state/animation/built-in.ts
@@ -70,7 +70,7 @@ export const AnimateModelIndex = PluginStateAnimation.create({
                 });
         }
 
-        await PluginCommands.State.Update.dispatch(ctx.plugin, { state, tree: update });
+        await PluginCommands.State.Update.dispatch(ctx.plugin, { state, tree: update, doNotLogTiming: true });
 
         if (params.mode.name === 'once' && isEnd) return { kind: 'finished' };
         if (params.mode.name === 'palindrome') return { kind: 'next', state: { palindromeDirections } };
diff --git a/webpack.config.js b/webpack.config.js
index 3a2db2529..b1e30e9ef 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -49,6 +49,8 @@ const sharedConfig = {
         }),
         new webpack.DefinePlugin({
             __PLUGIN_VERSION_TIMESTAMP__: webpack.DefinePlugin.runtimeValue(() => `${new Date().valueOf()}`, true),
+            // include this for production version of React
+            // 'process.env.NODE_ENV': JSON.stringify('production')
         }),
         new MiniCssExtractPlugin({ filename: 'app.css' })
     ],
-- 
GitLab