Creating web-component with vitejs
See original GitHub issueIs your feature request related to a problem? Please describe. Hi i try creating a web-component from the generated sfc file: i run in the following issues: App.vue is not able to have params. Component have no styles Bundler doesnt provide the outputformat
Describe the solution you’d like
i would have something like in the vue-cli target webc
…
i must be possible to set inline styles for using the shadow-dom
Describe alternatives you’ve considered create a own small script in the main.js
import { createApp } from 'vue'
import App from './App.vue';
import './index.scss';
const components = document.getElementsByTagName('my-app');
for(let i = 0; i < components.length;i++) {
const element = components[i];
const style = window.getComputedStyle(element);
const inlineStyle = document.createElement('style');
inlineStyle.textContent = style;
element.attachShadow({mode: 'open'});
element.shadowRoot.appendChild(inlineStyle);
createApp(App).mount(element.shadowRoot);
}
Additional context thanks for this wonderful web dev build tool we from the mercedes-benz.io seamless-web initiative really happy about it. If help is needed here we are happy to support you actively
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Create Web Components with Lit Element, Vite, and Tailwind
In this post you'll find a cool starter kit to develop web components with all these frontend technologies inside. How to Creare a...
Read more >Using Native Web Components with Vite (The New ... - YouTube
How to build a landing page with Tailwind CSS, Tailwind UI, Vite.js – tutorial video. Justin Jackson. Justin Jackson.
Read more >How to make Vue and Vite work with web components?
Tell Vite that all components starting with "foo-" are webcomponents. isCustomElement: (tag) => tag.startsWith('foo-'). Add "postcssLit" plugin ...
Read more >Getting Started with Web Components & Lit | Part 2
Vite created an index.html which you should open and edit by double-clicking it on the left. Notice that the page already has a...
Read more >Publish Web Components using Vite, Lit and Storybook
npm create vite@latest my-webcomponents -- --template lit-ts ... 'vite' // https://vitejs.dev/config/ export default defineConfig({ build: ...
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
The library mode is not enough for building a web-component based project, think about this situation:
A project includes multiple custom elements, we want to dev or build the project, so we need to
@DrMabuse23 Am I right?
We are also thinking about switching from gridsome to vite for our tiptap docs. We provide many (50+) interactive demos (JS/Vue/React) which should not affected by the styling of the doc pages and vice versa. Shadow DOM would be a great way to encapsulate these demos.