NickHurst / nuxt-quasar

Nuxt module for the Quasar Framework
38 stars 6 forks source link

Fixes plugin template and build error if missing assets/quasar.variables.style #2

Closed NickHurst closed 5 years ago

NickHurst commented 5 years ago

Previously if some of quasar's config properties were omitted, the module would generate an invalid plugin (see #1 for more):

Vue.use(Quasar, {
  config: ,
  components: {
,
  },
  directives: {
,
  },
  plugins: {
,
  },
  iconSet,
});

Now the properties will only get added if the property exists and is populated in the config, so now the config:

export default {
  mode: 'universal',
  head: {
    title: process.env.npm_package_name || '',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: process.env.npm_package_description || '' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
    ]
  },
  loading: { color: '#fff' },
  modules: [
    'nuxt-quasar',
  ],
  quasar: {
    framework: {
      components: ['QBtn']
    },
  }
}

Will generate the plugin file:

import Vue from 'vue';

import Quasar, {
  QBtn,
} from 'quasar/src/index.esm';

import iconSet from 'quasar/icon-set/material-icons.js';

Vue.use(Quasar, {
  components: {
    QBtn,
  },
  iconSet,
});

This also fixes a bug where if the ./assets/quasar.variables.styl file didn't exist the build would fail.