Get date when the compile command is executed.
-
How is it possible for me to capture the date each time the quasar build command is run within a spa application?
-
@mrcalvo I have something like this in “quasar.conf.js”
function formatDate (date) { if (!date) { date = new Date() } var year = date.getFullYear(), month = ('0' + (date.getMonth() + 1)).slice(-2), // months are zero indexed day = ('0' + date.getDate()).slice(-2), hour = ('0' + date.getHours()).slice(-2), minute = ('0' + date.getMinutes()).slice(-2), second = ('0' + date.getSeconds()).slice(-2) return year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second } module.exports = function (ctx) { ... const appenv = ctx.dev ? { // so on dev we'll have } : { // and on build (production): } let builddate = formatDate() ... appenv['MAIN_BUILD_DATE'] = JSON.stringify(builddate)
and later in configuration:
build: { ... env: appenv, ...
In vue/js files it is accessible as:
console.log(process.env.MAIN_BUILD_DATE)