How to Create NPM packages from a .vue file

纵然是瞬间 提交于 2019-12-05 01:39:34

问题


I have a index.js file with:

import MyComponent from './components/MyComponent.vue';
module.exports = MyComponent;

I want to publish this as npm package so that i can use this component by npm install my-component

When i try to test by importing component from compiled js file got [Vue warn]: Failed to mount component: template or render function not defined

But work fine when i import from .vue file.


回答1:


You just need to add a package.json in the directory and in main field of package.json add primary entry point to your component.

You can have a look at this simple npm component: vue-just-another-dropdown, which will give you more idea.



来源:https://stackoverflow.com/questions/41374223/how-to-create-npm-packages-from-a-vue-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!