Import constants file for entire project to use
-
I have a constants.js file where I put all my constants.
Currently, I just import it on every file as:import * as constants from '../scripts/constants.js'
And use them like this:
constants.SOMEVARIABLE
But it is too cumbersome IMO. Is there a way to import this file for the entire project to use? (Similar to when I want to add my own css, I just added under the css array in
quasar.conf.js
Thanks in advance!
-
You can hook it onto the Vue prototype with a boot file, so that you’d then have
this.$consts.SOME-CONSTANT
available in the components.https://quasar.dev/quasar-cli/cli-documentation/boot-files#Introduction
Scott