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

fix: application version getter #222

Merged
merged 1 commit into from Apr 18, 2021
Merged

fix: application version getter #222

merged 1 commit into from Apr 18, 2021

Conversation

jef
Copy link
Contributor

@jef jef commented Apr 18, 2021

fix: application version getter

Currently, when webpack bundles the Vue application, it no longer has access to process.env. I've updated the webpack plugins to include this in the build and the application now has access to the value.

Ref: #212

I tested putting via npm run serve as well as npm run build and using it like we would in production. In both cases, seemed to be working fine!

PR Checklist

  • I've started from master
  • I've only committed changes related to this PR
  • All Unit tests pass
  • I've removed all commented code
  • I've removed all unneeded console.log statements

Comment on lines -103 to -106
new webpack.DefinePlugin({
APPLICATION_VERSION: JSON.stringify(
require('./package.json').version
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This wasn't in use, so I decided to have it be in use! 😁

@WDaan
Copy link
Collaborator

WDaan commented Apr 18, 2021

aha, so 'APPLICATION_VERSION' is known by default when building with webpack?

@jef
Copy link
Contributor Author

jef commented Apr 18, 2021

Yep! The EnvironmentPlugin specifies that this is a process.env scoped variable. If we use DefinePlugin, I think it's on the global scope. Not sure how that's referenced, but it seemed to me EnvironmentPlugin was shorthand for

new webpack.DefinePlugin({
  'process.env': { 'APPLICATION_VERSION': process.env['npm_package_version'] }
})

Thus, webpack allows the VueJS app to view these at runtime, since they are compiled in.

@WDaan
Copy link
Collaborator

WDaan commented Apr 18, 2021

Awesome! thx for this fix 🙂

@WDaan WDaan merged commit 6535ac5 into VueTorrent:master Apr 18, 2021
@jef jef deleted the fix/app-version branch April 18, 2021 14:54
@jef
Copy link
Contributor Author

jef commented Apr 18, 2021

Thanks for the quick turn around!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants