Code that run at compile-time vs code that run at runtime

Viewed 1315

I'm new to Vue and Webpack. I have recently generated a static web app using vue-cli, and played with it for a while. Here is a snippet in src/components/hello.vue:

export default {
  name: 'hello',
  data () {
    return {
      msg: process.env.NODE_ENV
    }
  }
}

I recognized that the expression process.env.NODE_ENV is evaluated at compile-time. My questions are

  1. how can I tell if an expression is evaluated at compile-time or at runtime (i.e. on the browsers) since it is a valid javascript expression in either case?
  2. can I define functions that run at compile-time?
1 Answers
Related