Nuxt.js - console.log build version

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Nuxt.js - console.log build version



I'm hosting a Nuxt site on AWS S3 w/ Cloudfront, so when deploying I need to invalidate the CloudFront CDN. This means it takes a bit for the deploy to



I'd like to console.log(buildHash) when the application starts. What's the best way to do this?


console.log(buildHash)



I could add this to a plugin, but what's the best way to get the build hash?



There is a manifest.xxx.js file which seems to hold build hashes of the other files in the project. Is that manifest hash unique for each unique build?



Thanks!




1 Answer
1



This is a bit of a tumbleweed. Here's what I did:



A plugin to print the manifest hash:


```
// Statup and small stuff
window.onNuxtReady(() =>
// Print build version of this script
var scripts = window.document.getElementsByTagName('script')
for (var i=0; i < scripts.length; i++)
// Get the script name
var src = scripts[i].src
src = src.substr(src.lastIndexOf('/') + 1)
if (src && src.startsWith('manifest')) console.log('Hello ' + src)

)

```



Added to nuxt.config.js


nuxt.config.js


```
plugins: [
'plugins/bootstrap-vue.js',
'plugins/scroll.js',
ssr: false, src: '~plugins/etc.js' ,
]
```






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard