Creating custom app templates for quasar-cli



  • I’m sure there must be some documentation about this, but I just can’t find it on the docs site. Is there a guide anywhere for creating and using a custom app template with quasar init? I had a look in the source code, and it seems like just using a URL might work, but what format data does it expect back? Is it possible to use ‘local’ templates via a file / path reference? Is it possible to ‘register’ these with quasar-cli and use them by name?

    Many thanks!



  • I think you can only add your own template repo (from Github). For instance,

    quasar init smolinari/my-own-super-duper-quasar-template-repo new-app

    Scott



  • Thanks - I tried a few things, and forked the existing template. Then I found the correct format for the init command:

    quasar init @myrepo/quasar-template-default test
    

    The @ is crucial - otherwise it tries to load a sub-version of the official template.



  • And do you know how to refer to a specific branch on that repo? And also how to specify a local folder?


  • Admin

    @dpamio for branch use #. Example: quasar init @myrepo/quasar-template-default#some_branch test



  • Ouch! I was almost sure it was that way but I may had some typo in other place because it didn’t work. Will try again.



  • I’ve updated the docs to mention the hash.

    Scott



  • Hey guys!
    I have a lot of custom templates that I use across multiple projects, but are not things I can upload to NPM or anything.
    It’s mainly 4 categories I’m talking about: Vuex module templates, Vue component templates, Stylus helper files, build/config files.

    The problem is, I need these sporadically throughout my projects, not just on the initial init of Quasar. Similar to the Quasar new plugin command!
    I want to find a method where I could have a single source of truth where I keep all my templates, then just have a name for each file, and be able to template install assigned-name or something in any project I have.

    Now I’m manually copy pasting them from a folder on my desktop whenever I need them. : D not ideal… Any advice greatly appreciated!

    These are the things I have templates for:

    • Vuex store modules:
      • a main module.js template which has some preset mutations I use to write any new module on
      • a modal management module
      • a collection management module
      • a generic api pre-set modal, etc.
    • Vue components:
      • a main component.js template with some standard computed props / mixins / stylus setup I use to write any new component on
      • extra wrappers with custom settings around quasar components
      • a modal aggregation component linked to modals vuex module
      • signin/signup mocks, etc.
    • Stylus helpers:
      • I often write helper files with some functions/mixins meant for general use
      • Stuff like my own breakpoint wrappers, my own margin padding mixin system, etc.
    • Build/config files:
      • Configuration files for things like: rollup, wallaby, babelrc, eslint, etc…

  • Admin

    Use vue init <user>/<repo> 🙂



  • @rstoenescu Thanks. I’m trying to install a helpers folder I have in a private repo on Github:

    vue init mesqueeb/templates/tree/master/styles/helpers helpers
    // but I get:
    (node:58697) ExperimentalWarning: The fs.promises API is experimental
       vue-cli · Failed to download repo mesqueeb/templates/tree/master/styles/helpers: Response code 404 (Not Found)