├── .eslintrc.cjs ├── .github └── workflows │ └── main.yml ├── .gitignore ├── .husky └── pre-commit ├── .prettierrc.json ├── .vscode └── extensions.json ├── LICENSE ├── README.md ├── index.html ├── package.json ├── src ├── App.vue ├── components │ ├── Button.vue │ └── index.ts ├── main.ts └── vite-env.d.ts ├── tsconfig.config.json ├── tsconfig.json ├── tsconfig.node.json ├── vite.config.ts └── yarn.lock /.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | require('@rushstack/eslint-patch/modern-module-resolution') 3 | 4 | module.exports = { 5 | root: true, 6 | extends: [ 7 | 'plugin:vue/vue3-essential', 8 | 'eslint:recommended', 9 | '@vue/eslint-config-typescript', 10 | '@vue/eslint-config-prettier', 11 | ], 12 | parserOptions: { 13 | ecmaVersion: 'latest', 14 | }, 15 | } 16 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | push: 4 | branches: [master] 5 | pull_request: 6 | branches: '*' 7 | permissions: 8 | contents: write 9 | jobs: 10 | quality: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v3 14 | - name: Use Node.js 15 | uses: actions/setup-node@v3 16 | with: 17 | node-version: 18 18 | - run: yarn 19 | - run: yarn lint 20 | publish: 21 | runs-on: ubuntu-latest 22 | if: ${{ github.ref == 'refs/heads/master' }} 23 | needs: [quality] 24 | steps: 25 | - uses: actions/checkout@v3 26 | - name: Use Node.js 27 | uses: actions/setup-node@v3 28 | with: 29 | node-version: 18 30 | - run: yarn 31 | - run: yarn build 32 | - run: yarn semantic-release 33 | env: 34 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 35 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 36 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | .DS_Store 12 | dist 13 | dist-ssr 14 | coverage 15 | *.local 16 | 17 | /cypress/videos/ 18 | /cypress/screenshots/ 19 | 20 | # Editor directories and files 21 | .vscode/* 22 | !.vscode/extensions.json 23 | .idea 24 | *.suo 25 | *.ntvs* 26 | *.njsproj 27 | *.sln 28 | *.sw? 29 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | . "$(dirname -- "$0")/_/husky.sh" 3 | 4 | npx lint-staged 5 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "semi": false, 3 | "singleQuote": true, 4 | "tabWidth": 4, 5 | "printWidth": 120 6 | } 7 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"] 3 | } 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Antério Vieira 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | 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, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vite-vue-lib-template 2 | 3 | > Fully automated. 4 | 5 | - [x] Eslint 6 | - [x] Prettier 7 | - [x] Conventional Commit 8 | - [x] Pre-commit 9 | - [x] Lint-staged 10 | - [x] Semantic-release 11 | - [x] TypeScript 12 | 13 | ## How to use: 14 | 15 | 1. Clone the project 16 | 2. `yarn` 17 | 3. `npx semantic-release-cli setup` 18 | 4. Add components 19 | 5. `git add .` 20 | 6. `yarn commit` 21 | 7. `git push` 22 | 23 | ## Real Example: 24 | 25 | [vue-tradingviewWidgets](https://github.com/ehsan-shv/vue-tradingviewWidgets) 26 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vite App 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vite-vue-lib-template", 3 | "version": "0.0.0-development", 4 | "private": false, 5 | "description": "Vite Vue lib template.", 6 | "author": "Ehsan Shahvirdi", 7 | "license": "MIT", 8 | "files": [ 9 | "dist" 10 | ], 11 | "keywords": [ 12 | "vue", 13 | "vite", 14 | "template" 15 | ], 16 | "type": "module", 17 | "main": "./dist/vite-vue-lib-template.umd.cjs", 18 | "module": "./dist/vite-vue-lib-template.js", 19 | "types": "./dist/index.d.ts", 20 | "exports": { 21 | ".": { 22 | "import": "./dist/vite-vue-lib-template.js", 23 | "require": "./dist/vite-vue-lib-template.umd.cjs" 24 | }, 25 | "./*": "./dist/vite-vue-lib-template.js" 26 | }, 27 | "scripts": { 28 | "dev": "vite", 29 | "build": "vue-tsc && vite build", 30 | "preview": "vite preview", 31 | "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore", 32 | "format": "prettier . --write --ignore-path .gitignore", 33 | "prepare": "husky install", 34 | "commit": "git-cz" 35 | }, 36 | "dependencies": { 37 | "vue": "^3.2.45" 38 | }, 39 | "devDependencies": { 40 | "@rushstack/eslint-patch": "^1.1.4", 41 | "@types/node": "^18.11.12", 42 | "@vitejs/plugin-vue": "^4.0.0", 43 | "@vue/eslint-config-prettier": "^7.0.0", 44 | "@vue/eslint-config-typescript": "^11.0.0", 45 | "@vue/tsconfig": "^0.1.3", 46 | "cz-conventional-changelog": "3.3.0", 47 | "eslint": "^8.22.0", 48 | "eslint-plugin-vue": "^9.3.0", 49 | "husky": "^8.0.0", 50 | "lint-staged": "^13.1.0", 51 | "npm-run-all": "^4.1.5", 52 | "pathe": "^1.1.0", 53 | "prettier": "^2.7.1", 54 | "typescript": "~4.7.4", 55 | "vite": "^4.0.0", 56 | "vite-plugin-dts": "^1.7.1", 57 | "vue-tsc": "^1.0.12", 58 | "semantic-release": "^20.1.0" 59 | }, 60 | "lint-staged": { 61 | "*.{js,ts,vue}": "eslint --fix", 62 | "*.{js,ts,vue,css,scss,json,md}": "prettier --write" 63 | }, 64 | "config": { 65 | "commitizen": { 66 | "path": "./node_modules/cz-conventional-changelog" 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/components/Button.vue: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/components/index.ts: -------------------------------------------------------------------------------- 1 | export { default as Button } from './Button.vue' 2 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { createApp } from 'vue' 2 | import App from './App.vue' 3 | 4 | createApp(App).mount('#app') 5 | -------------------------------------------------------------------------------- /src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | declare module '*.vue' { 4 | import type { DefineComponent } from 'vue' 5 | const component: DefineComponent<{}, {}, any> 6 | export default component 7 | } 8 | -------------------------------------------------------------------------------- /tsconfig.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@vue/tsconfig/tsconfig.node.json", 3 | "include": ["vite.config.*", "vitest.config.*", "cypress.config.*", "playwright.config.*"], 4 | "compilerOptions": { 5 | "composite": true, 6 | "types": ["node"] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "useDefineForClassFields": true, 5 | "module": "ESNext", 6 | "moduleResolution": "Node", 7 | "strict": true, 8 | "jsx": "preserve", 9 | "resolveJsonModule": true, 10 | "isolatedModules": true, 11 | "esModuleInterop": true, 12 | "lib": ["ESNext", "DOM"], 13 | "skipLibCheck": true, 14 | "noEmit": true 15 | }, 16 | "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.vue"], 17 | "references": [{ "path": "./tsconfig.node.json" }] 18 | } 19 | -------------------------------------------------------------------------------- /tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "module": "ESNext", 5 | "moduleResolution": "Node", 6 | "allowSyntheticDefaultImports": true 7 | }, 8 | "include": ["vite.config.ts"] 9 | } 10 | -------------------------------------------------------------------------------- /vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import vue from '@vitejs/plugin-vue' 3 | import dts from 'vite-plugin-dts' 4 | import { resolve } from 'pathe' 5 | 6 | export default defineConfig({ 7 | resolve: { 8 | alias: { 9 | '/@': resolve(__dirname, './src'), 10 | }, 11 | }, 12 | plugins: [ 13 | vue(), 14 | dts({ 15 | insertTypesEntry: true, 16 | }), 17 | ], 18 | build: { 19 | lib: { 20 | entry: resolve(__dirname, 'src/components/index.ts'), 21 | name: 'vite-vue-lib-template', 22 | fileName: 'vite-vue-lib-template', 23 | }, 24 | watch: { 25 | include: [resolve(__dirname, 'src')], 26 | }, 27 | rollupOptions: { 28 | external: ['vue'], 29 | output: { 30 | exports: 'named', 31 | globals: { 32 | vue: 'Vue', 33 | }, 34 | }, 35 | }, 36 | }, 37 | optimizeDeps: { 38 | exclude: ['vue'], 39 | }, 40 | }) 41 | --------------------------------------------------------------------------------