No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Get date when the compile command is executed.

    CLI
    2
    2
    230
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      mrcalvo last edited by

      How is it possible for me to capture the date each time the quasar build command is run within a spa application?

      qyloxe 1 Reply Last reply Reply Quote 0
      • qyloxe
        qyloxe @mrcalvo last edited by

        @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)
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post