Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APP-23022: Define the static variable __DEV__ #163

Merged
merged 1 commit into from
Aug 2, 2021

Conversation

alexisfontaine
Copy link
Member

@alexisfontaine alexisfontaine commented Aug 2, 2021

Automatically created JIRA issue: APP-23022

@alexisfontaine alexisfontaine added the autorelease Automatically create a release after all PRs with this label have been merged label Aug 2, 2021
@habxtech habxtech changed the title Define the static variable __DEV__ APP-23022: Define the static variable __DEV__ Aug 2, 2021
@habxtech habxtech requested review from Carolinevp and jean9696 August 2, 2021 11:11

const helpers = require('../helpers')
const customConfig = require('./webpack.config')

module.exports = (defaultConfig) => {
let config = merge({}, defaultConfig, customConfig)

config.plugins.unshift(new webpack.DefinePlugin({
__DEV__: JSON.stringify(process.env.NODE_ENV !== "production"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to stringify a Boolean ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I copy-pasted it 😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hint: I never use double quotes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this results in a string instead of boolean 🤔 Weird...

@habx-auto-merge habx-auto-merge bot merged commit 1611c04 into dev Aug 2, 2021
@habx-auto-merge habx-auto-merge bot deleted the feature/build-variable branch August 2, 2021 11:32
@benjamn
Copy link

benjamn commented Aug 3, 2021

Drive-by comment: I misinterpreted https://webpack.js.org/plugins/define-plugin/#usage as suggesting that JSON.stringify was the way to include that string's value as code, but (reading the rest of the rules) it turns out JSON.stringify is only necessary when the value is already a string (to preserve the quotation marks). Other values will be stringified automatically, and true and false have no trouble with that. Simplified in apollographql/react-apollo-error-template#57.

@habxtech habxtech added the usage label Aug 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autorelease Automatically create a release after all PRs with this label have been merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants