Build Vue Components as standalone components
See original GitHub issueVersion
3.0.0-beta.6
Reproduction link
https://codesandbox.io/s/k2qojnor8o
Steps to reproduce
I am using Vue cli and I have a components directory structure like this
- components
- button
- button.scss
- button.vue
- index.js
index.js // imports all components
What is expected?
I want to get my build files like this
- build
- button.js
- button.css
- index.js
- components.css
What is actually happening?
It bundles the entire components into one component
I use vue-cli-service build --target lib
and after that, I get
- build
- app.2fa32eb.css
- app.fa24cd4.js
Is it possible to do this with Vue cli, or do I have to use a custom build.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:21
- Comments:15 (3 by maintainers)
Top Results From Across the Web
How To Create Reusable Blocks of Code with Vue Single-File ...
In this tutorial, you created single-file components and used props and slots to create reusable blocks of code. In the project, you created...
Read more >Single-File Components - Vue.js
Vue Single-File Components (a.k.a. *.vue files, abbreviated as SFC) is a special file format that allows us to encapsulate the template, logic, ...
Read more >Is it possible to build a Standalone Vue app? - Stack Overflow
So, it was actually simpler than I thought: I just created a separate entry file for webpack to consume like my-custom-component-entry.js.
Read more >Building a Vue 3 component library - LogRocket Blog
Creating components in Vue ... A component library will, of course, need some components. Let's create an src folder and add the following...
Read more >How to create, publish and use your own VueJS Component ...
Step 1 — Setting up the library build · Step 2 — Pointing towards your output file in package. · Step 3 —...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kayandrae07 : Could you maybe share a GitHub repository for the workaround you’ve come up with? It would be really helpful for people who might end up referencing this issue even later. Also, this could become a really cool medium article.
@renoirb I’m using the solution you provided above, but I’m building the combination of all the components first. Then you can build the individual components.
Another thing I noticed is that you have to add the / after the folder name in the
dest
option like this:For the main time, this is what I have working
I also set
dist
as main inpackage.json
. So in my application I can require like thisThe second import format is a bit stressful, so I wrote a little script that runs after building the components. The script iterates the directories and renames any file ending with
.common.js
intoindex.js
.