Skip to content

Commit

Permalink
Make umd debug build work without 'process' global (mobxjs#1351)
Browse files Browse the repository at this point in the history
* Make devMode() work without process global

* bind development environment to development build

* set the NODE_ENV only for debug umd-builds
  • Loading branch information
leon-vg authored and xaviergonz committed Oct 6, 2019
1 parent 3747632 commit 2ec5c65
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion rollup.base-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ import replace from "rollup-plugin-replace"

const devPlugins = () => [resolve(), filesize()]

// For umd builds, set process.env.NODE_ENV to "development" since 'process' is not available in the browser
const devPluginsUmd = () => [
resolve(),
replace({ "process.env.NODE_ENV": JSON.stringify("development") }),
filesize()
]

const prodPlugins = () => [
resolve(),
replace({ "process.env.NODE_ENV": JSON.stringify("production") }),
Expand All @@ -22,5 +29,6 @@ export const baseConfig = ({ input, globals, umdName, external, outFile, format,
name: format === "umd" ? umdName : undefined
},
external,
plugins: mode === "production" ? prodPlugins() : devPlugins()
plugins:
mode === "production" ? prodPlugins() : format === "umd" ? devPluginsUmd() : devPlugins()
})

0 comments on commit 2ec5c65

Please sign in to comment.