-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
DefinePlugin / add support for watch mode #7717
Comments
The module need to marked as non-cacheable to support this behavior. The |
thx! this.plugins.push(new webpack.DefinePlugin({
'app.env': {
'appVersion': `"${this.settings.appVersion}"`,
'appHash': `"${this.settings.appHash}"`,
'buildNr': webpack.DefinePlugin.runtimeValue(() => `"${this.settings.buildNr}"`, []),
'apiPath': `"${process.env.APP_APIPATH}"`,
'stage': `"${this.configuration.mode}"`,
}
})); |
Thanks @crazyx13th it does work! |
For anybody wondering, this is how you provide a runtime define variable: // webpack.config.js
const webpack = require('webpack')
module.exports = {
plugins: [
new webpack.DefinePlugin({
MY_VARIABLE_NAME: webpack.DefinePlugin.runtimeValue(
() => JSON.stringify('ANY_VALUE'),
// Passing the second argument as `true` reevaluates the defined expression.
// Beware that this disables module caching and must be used with caution.
true,
),
})
]
} |
Feature request
What is the expected behavior?
For Example: I have a build nr, which increments each "runWatch" hook. But DefinePlugin only define variables at start, not on re-compile.
What is motivation or use case for adding/changing the behavior?
Now you can use a Function as a value (#6749). DefinePlugin only should update value with this defined function.
How should this be implemented in your opinion?
Only update values with the user defined function. Many other Plugins use a function for updates values on re-compile.
Are you willing to work on this yourself?
I will support this as good as I can :-)
The text was updated successfully, but these errors were encountered: