From 056e8170311c77b8e42e81fac9e434a1cc4ca559 Mon Sep 17 00:00:00 2001 From: moklick Date: Fri, 23 Oct 2020 14:06:31 +0200 Subject: [PATCH] refactor(rollup): use replace plugin before other plugins --- rollup.config.js | 9 +++++---- src/container/ReactFlow/index.tsx | 2 +- src/store/index.ts | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/rollup.config.js b/rollup.config.js index 18b5986d..3191135d 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -36,6 +36,10 @@ export default [ }, ], plugins: [ + replace({ + __ENV__: JSON.stringify(processEnv), + __REACT_FLOW_VERSION__: JSON.stringify(pkg.version), + }), bundleSize(), postcss({ minimize: isProd, @@ -44,10 +48,7 @@ export default [ exclude: 'node_modules/**', babelHelpers: 'runtime', }), - replace({ - __ENV__: JSON.stringify(processEnv), - __REACT_FLOW_VERSION__: JSON.stringify(pkg.version), - }), + svgr(), typescript({ clean: true, diff --git a/src/container/ReactFlow/index.tsx b/src/container/ReactFlow/index.tsx index 7b67d7e7..dd6d0507 100644 --- a/src/container/ReactFlow/index.tsx +++ b/src/container/ReactFlow/index.tsx @@ -1,7 +1,7 @@ import React, { useMemo, CSSProperties, HTMLAttributes, MouseEvent, WheelEvent } from 'react'; import cc from 'classcat'; -const nodeEnv: string = __ENV__ as string; +const nodeEnv: string = (typeof __ENV__ !== 'undefined' && __ENV__) as string; if (nodeEnv !== 'production') { const whyDidYouRender = require('@welldone-software/why-did-you-render'); diff --git a/src/store/index.ts b/src/store/index.ts index 4b011018..445f5968 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -511,7 +511,7 @@ export const storeModel: StoreModel = { }), }; -const nodeEnv: string = __ENV__ as string; +const nodeEnv: string = (typeof __ENV__ !== 'undefined' && __ENV__) as string; const store = createStore(storeModel, { devTools: nodeEnv === 'development' }); export default store;