An open API service indexing awesome lists of open source software.

https://github.com/hasanabbadi/vue-cdn-template

A template with support for components when using Vue via CDN
https://github.com/hasanabbadi/vue-cdn-template

cdn template vue vue3

Last synced: 3 months ago
JSON representation

A template with support for components when using Vue via CDN

Awesome Lists containing this project

README

        

# Vue CDN Components Template

### Why does this exist?

- Vue cdn doesn't support components, this is a temporary bandaid.
- Useful for quick prototypes / messing around
- No build step, no tooling to waste your time and storage

### Example

```html

Hello {{ name }}!
Count is: {{ count }}

export default {
props: ["name"],
data: () => ({ count: 0 }),
};

```

```js
// index.html



// ...
import VueCDNParser from "./parser.js";
const parser = new VueCDNParser();
// ...
await parser.use("/src/components/counter.html");
// ...

```

## Quick Start

Clone the template and modify it to your liking:

```bash
git clone https://github.com/HasanAbbadi/vue-cdn-template
python -m http.server # or: npx http-server
```

or add the script to your import map and use it yourself:

```html

{
"imports": {
// this shouldn't be used in production,
// but it's fine since this is a prototyping tool
"parser": "https://cdn.jsdelivr.net/gh/HasanAbbadi/vue-cdn-template/parser.min.js"
}
}

```

## Limitations

Being a hacky solution, it has some limitations (for now):

- No imports in components (other than nested components)
- No self-closing tags
- ~~Scoped styles apply to nested components~~ (fixed)
- ~~No nested components~~ (fixed using imports)
- ~~No scoped styles~~ (fixed)
- ~~No slots~~ (already existed :P)

## Default Project Structure

```
├── index.html # Your app entry
├── src/
│ ├── components/*.html # Components live here
│ └── css/ # Your styles
└── parser.js # What makes it work
```

## Contributing

Got ideas? PRs are appreciated.

## License

MIT