Quasar: Auto adding of components / plugins / directives when needed in Quasar.conf.js

Created on 1 Jul 2019  路  8Comments  路  Source: quasarframework/quasar

Is your feature request related to a problem? Please describe.
When we add a component, plugin or directive in our projects we currently have to add that component to quasar config file. This step is sometimes missed by new people and causes confusion.

Describe the solution you'd like
When you save, the missing components etc should automatically be added to the quasar conf file.

Describe alternatives you've considered
Doing it manually as we do. Quasar handles so many other tasks for us, it'd be nice for it to do the same here as well.

Additional context
I've created an App Extension that is already doing this for components but it's been suggested that we move it to @quasar/app in core instead.

After discussions with @lucasfernog and @hawkeye64 this is what I propose:

  1. New cli command quasar check - This will provide a list of missing components / plugins / directives
  2. New cli command quasar check -fix - This will fix the missing components / plugins / directives
  3. New quasar.conf.js section (below)
code: {
  dev: {
    check: true,
    fix: true
  },
  prod: {
    check: true,
    fix: true
  }
}

When these options are set, the loader will be used and check / update the quasar.conf.js file with the missing components / plugins / directives.

How it works:

  1. I'm using a loader called ware-loader (the same one @hawkeye64 uses for QMarkdown) which gives me the source code for the SFC's.
  2. Use regex to get all the Quasar tags
  3. Strip out any misc tags that aren't in a whitelist (in case a user adds a q-something component of their own.
  4. Compare the current quasar.conf components etc with the ones found via the regex and add the missing ones to the quasar.conf file.

HMR will do the rest as we save the files.

feature request

All 8 comments

I like this idea... constantly adding things to the config feels like unnecessary work for a beginner in Quasar (i.e. someone like me). One of the reasons I like Quasar is to go ahead and be a little opinionated on the controls. I just don't understand why they're aren't all included by default. Seems to me.... rather than crazy engineering to add them to a config file... could we just make the default to add all Quasar components... and allow advanced config for people who need to do something else (other conflicting component libraries, etc). I'm sure there are implications... but... ignorance is bliss. ;)

I love the idea, but I think it shouldn't add new sections to the quasar.conf.js as I think it increases its complexity. A new prop on "devServer" and "build" is better IMO.

And make it opinionated for build and just assume yes to check and fix? @hawkeye64 Any thoughts on this as it was your idea initially for the new section?

@rfox12 it works like that coz including all components has an overhead, you can set framework: 'all' in quasar.conf.js file if you want to load all of it tho ftm, while this feature being discussed is still in the works.

The list of Quasar components/plugins can be read from node_modules/quasar/dist/api so we can use that to know if a Q tag is from Quasar or not @webnoob

devServer, I believe is a section that is sent to webpack-dev-server. So anything you put in there could potentially have future conflicts. Razvan would know for sure.

As it stands, this is being worked on as an AE: https://github.com/webnoob/app-extension-qautomate

Once it's stable and has all the feature's we're looking for, we'll review the potential of promoting it to core code.

This feature will be available in core starting with @quasar/app v1.1.0. More info here: https://github.com/quasarframework/quasar/issues/5080

Was this page helpful?
0 / 5 - 0 ratings