Skip to content

Commit

Permalink
Fix webpack configuration by only adding custom env vars to the "Defi…
Browse files Browse the repository at this point in the history
…nePlugin" (they were added to "ProvidePlugin" too, by mistake)
  • Loading branch information
Vadorequest committed May 8, 2021
1 parent 3ed6e66 commit e9a1f4d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ module.exports = withBundleAnalyzer(withSourceMaps({

const APP_VERSION_RELEASE = APP_RELEASE_TAG || buildId;
config.plugins.map((plugin, i) => {
if (plugin.definitions) { // If it has a "definitions" key, then we consider it's the DefinePlugin where ENV vars are stored
// Inject custom environment variables in "DefinePlugin" - See https://webpack.js.org/plugins/define-plugin/
if (plugin.__proto__.constructor.name === 'DefinePlugin') {
// Dynamically add some "public env" variables that will be replaced during the build through "DefinePlugin"
// Those variables are considered public because they are available at build time and at run time (they'll be replaced during initial build, by their value)
plugin.definitions['process.env.NEXT_PUBLIC_APP_BUILD_ID'] = JSON.stringify(buildId);
Expand Down

0 comments on commit e9a1f4d

Please sign in to comment.