So I want to use https://github.com/niksmr/vue-masked-input in my app.
I tried several variations of including/importing this plugin into my nuxt app but every single one failed. I always get the following error:
clientErrorHandler err /Users/Patrick/dev/server/node_modules/vue-masked-input/dist/maskedInput.js:3
import InputMask from 'inputmask-core';
^^^^^^
SyntaxError: Unexpected token import
I already tried:
import MaskedInput from 'vue-masked-input'
import MaskedInput from '~/plugins/vue-masked-input'
and a plugin file with the following code:import Vue from 'vue'
import MaskedInput from 'vue-masked-input'
Vue.use(MaskedInput)
export default MaskedInput
The only solution working is including it in my component like so:
let MaskedInput;
if(proccess.browser) {
MaskedInput = require('vue-masked-input')
}
Problem is that, obviously, in that case on a server side render of the page the plugin is not loaded and thus can not be used in the template.
I am totally confused on how to use VueJS plugins like this one in a nuxt app properly.
Please help! Thanks a bunch!
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1697">#c1697</a>)</em></sub></div>