It is needed verify whether the latest build was deployed. I would like add timestamp on build log and in each file of the build output. I am using a Vue framework and yarn.
success Installed "[email protected]" with binaries: - create-vite - cva ✔ Select a framework: › vue ✔ Select a variant: › vue Scaffolding project in /Users/tony/src/tmp/my-vite-project... Done. Now run: cd my-vite-project yarn yarn dev ✨ Done in 38.38s.
You can verify that it is properly installed by simply running vue , which should present you with a help message listing all available commands.
The CLI ( @vue/cli ) is a globally installed npm package and provides the vue command in your terminal. It provides the ability to quickly scaffold a new project via vue create . You can also manage your projects using a graphical user interface via vue ui .
It is the standard tooling baseline for using Vue JS which provides you with the Vue CLI service which is a runtime dependency, built on Webpack with 0 configs. It has a very extensive collection of plugins you can add to your project with a line of command.
I needed to have a build timestamp in the output Vue app, not the logs.
(You could write to build logs by adding a console.log(new Date().toIsoString()) in the webpack part of vue.config.js.)
One way to get the build timestamp into to the app itself is to make use of the fact that webpack uses a simple template language in the HTML itself.
In the Vue app index.html (for example), I inserted a data attribute on the root <html> element:
<html data-build-timestamp-utc="<%= new Date().toISOString() %>">
...
</html>
That's easily retrieved:
document.documentElement.dataset.buildTimestampUtc
You can then add that as a getter on the root App component, @Provide it to other components as "buildtime", etc.
This works on a main build as well as a development "serve" build - but remember the root HTML itself doesn't hot-module-reload, so although the build timestamp is being updated, you'll have to refresh the page to see it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With