Skip to content

Commit c7b0fa1

Browse files
committed
feat: plugin
0 parents  commit c7b0fa1

File tree

10 files changed

+1688
-0
lines changed

10 files changed

+1688
-0
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# macOS
2+
.DS_Store
3+
4+
# Node.js
5+
node_modules/
6+
npm-debug.log
7+
8+
# Build directories
9+
dist/
10+
build/
11+
12+
# Environment files
13+
.env
14+
15+
# Logs
16+
logs/
17+
*.log
18+
19+
# IDE
20+
.vscode/
21+
.idea/

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025-present, Tom Heaton
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# vite-plugin-vue-template-selector [![npm](https://img.shields.io/npm/v/vite-plugin-vue-template-selector.svg)](https://npmjs.com/package/vite-plugin-vue-template-selector)
2+
3+
A Vite plugin for Vue.js that allows dynamic template selection at build time.
4+
5+
## Usage
6+
7+
### Select a template by name
8+
9+
```ts
10+
// vite.config.ts
11+
import vueTemplateSelector from "vite-plugin-vue-template-selector";
12+
13+
export default {
14+
plugins: [
15+
vueTemplateSelector({
16+
name: "default",
17+
}),
18+
],
19+
};
20+
```
21+
22+
### Create multiple templates
23+
24+
```vue
25+
<!-- Component.vue -->
26+
<template name="default">
27+
<div>
28+
<h1>Default Template</h1>
29+
</div>
30+
</template>
31+
32+
<template name="alternative">
33+
<div>
34+
<h1>Alternative Template</h1>
35+
</div>
36+
</template>
37+
38+
<script setup lang="ts">
39+
// logic can be shared across templates
40+
</script>
41+
```
42+
43+
## Options
44+
45+
```ts
46+
export type Options = {
47+
name?: string; // selected template name, defaults to "default"
48+
};
49+
```
50+
51+
## License
52+
53+
MIT

package.json

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"name": "vite-plugin-vue-template-selector",
3+
"version": "1.0.0-beta.1",
4+
"type": "module",
5+
"license": "MIT",
6+
"author": "Tom Heaton",
7+
"description": "A Vite plugin for Vue.js that allows dynamic template selection at build time.",
8+
"keywords": [
9+
"vite",
10+
"vite-plugin",
11+
"vue",
12+
"template",
13+
"template-selector"
14+
],
15+
"main": "./dist/index.js",
16+
"module": "./dist/index.js",
17+
"types": "./dist/index.d.ts",
18+
"exports": {
19+
".": {
20+
"import": "./dist/index.js",
21+
"types": "./dist/index.d.ts"
22+
},
23+
"./package.json": "./package.json"
24+
},
25+
"files": [
26+
"dist"
27+
],
28+
"scripts": {
29+
"build": "tsup",
30+
"typecheck": "tsc --noEmit",
31+
"prepublishOnly": "npm run build"
32+
},
33+
"engines": {
34+
"node": "^20.19.0 || >=22.12.0"
35+
},
36+
"repository": {
37+
"type": "git",
38+
"url": "git+https://github.com/tomheaton/vite-plugin-vue-template-selector.git"
39+
},
40+
"bugs": {
41+
"url": "https://github.com/tomheaton/vite-plugin-vue-template-selector/issues"
42+
},
43+
"homepage": "https://github.com/tomheaton/vite-plugin-vue-template-selector",
44+
"peerDependencies": {
45+
"@vue/compiler-dom": "^3.5.17",
46+
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0",
47+
"vue": "^3.5.17"
48+
},
49+
"devDependencies": {
50+
"tsup": "^8.5.0",
51+
"typescript": "^5.8.3",
52+
"vite": "^6.0.0",
53+
"vue": "^3.5.17"
54+
}
55+
}

0 commit comments

Comments
 (0)