Skip to content

Documentation for how to configure templates in v3 #862

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Comments

@philwolstenholme
Copy link
Contributor

philwolstenholme commented Feb 21, 2018

What problem does this feature solve?

In v2, it was easy to build a template that came with a custom index.html file and some default components. In v3 I'm not sure if this is possible, or if it is possible, how it is done.

I'm building a vue-cli template for my organisation and I'd like to benefit from the plugin based approach of v3, but also give my users something more than just the default HelloWorld components after they have run vue create. I'd like to supply some components and also a customised app shell, so would need to alter the contents of generator/template (https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-service/generator/template) - I guess?

Is this possible? It might be useful to document this either way as it will help users who wish to migrate from v2 to v3.

What does the proposed API look like?

Documentation change to either supply information on producing custom generator templates, or to specify that v2 should be used for this purpose.

@LinusBorg
Copy link
Member

LinusBorg commented Feb 21, 2018

Well, the intended way would be to write a plugin for that, and publish it.

Your plugin can ask the user additional prompts as well as copy over its own templates, check the docs that we have so far:

https://github.com/vuejs/vue-cli/blob/dev/docs/plugin-dev.md

We will certainly extend and imrpove these, e.g. to explain in more detail how api.render() can be used to render new template files etc.

So the workflow for your users would be:

npm i -D vue-cli-plugin-phils-template && vue create myApp && myApp/vue invoke phils-template

@philwolstenholme
Copy link
Contributor Author

Thank you @LinusBorg, I'd briefly scanned the plugin dev page but hadn't noticed the api.render('./template') line in the example.

I'll take a look at that page and see if I can get something working locally 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment