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:
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
Thanks in advance!
s.molinari last edited by s.molinari
You can hook it onto the Vue prototype with a boot file, so that you’d then have
this.$consts.SOME-CONSTANTavailable in the components.