vuejs / vue-cli

🛠️ webpack-based tooling for Vue.js Development
https://cli.vuejs.org/
MIT License
29.76k stars 6.33k forks source link

vue-cli-service serve does not mount component for individually specified entry file #2259

Open yongjun21 opened 6 years ago

yongjun21 commented 6 years ago

Version

3.0.1

Reproduction link

https://bitbucket.org/yongjun21/example/src/master/

Node and OS info

Node 8.11.3

Steps to reproduce

Run npx vue-cli-service serve src/components/Test.vue

What is expected?

Component mounted when index.html opened

What is actually happening?

Component not mounted. Though can be located in app.js


If I use cli-service-global (i.e. vue serve src/components/Test.vue), component gets mounted.

haoqunjiang commented 6 years ago

vue-cli-service serve is expected to serve apps only.

yongjun21 commented 6 years ago

In the docs, it's specified that we can supply an entry file. It seems weird that this is allowed if the purpose of vue-cli-service serve is only to serve app.

yongjun21 commented 6 years ago

Is there any plan to match the behavior for cli-service-global some time in future?

haoqunjiang commented 6 years ago

entry means app entry.

haoqunjiang commented 6 years ago

Ummm... I'm not sure. But you can have a try and open a PR on it. It is also doable by introducing a plugin.

The core logic of instant prototyping is here: https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-service-global/lib/globalConfigPlugin.js

yongjun21 commented 6 years ago

The reason I was asking this in the first place is because I am creating a UI library for my team and wants my developers and designers to be able to individually serve the Vue component they are working on. But turns out vue serve is not the best option also as often the UI components do not exist in isolation and requires some props to be passed in. So I ended up using Storybook.

But anyway thanks for clarifying. Will be helpful if this is mentioned in the doc: that vue serve is more for prototyping self contained components and tools like Storybook will have been more suited for prototyping components that requires context.