Skip to content

Instantly share code, notes, and snippets.

@matheus1lva
Created September 25, 2019 14:01
Show Gist options
  • Save matheus1lva/921fa1da9c73bbab883d968661265ccb to your computer and use it in GitHub Desktop.
Save matheus1lva/921fa1da9c73bbab883d968661265ccb to your computer and use it in GitHub Desktop.
module.exports = {
...
plugins: [
new webpack.DefinePlugin({
__DEV__: JSON.stringify(process.MY_ENV_VARIABLE)
}),
]
}
@sibelius
Copy link

sibelius commented Sep 25, 2019

why JSON.stringify?

@matheus1lva
Copy link
Author

matheus1lva commented Sep 25, 2019

From webpack docs:

Note that because the plugin does a direct text replacement, the value given to it must include actual quotes inside of the string itself. Typically, this is done either with alternate quotes, such as '"production"', or by using JSON.stringify('production').

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment