Skip to content

Commit e18f0c4

Browse files
committed
add basic nuxt boilerplate
1 parent a18cfe7 commit e18f0c4

File tree

10 files changed

+139
-0
lines changed

10 files changed

+139
-0
lines changed

template/.pre-commit-config.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,34 @@ repos:
162162

163163
# Linting
164164

165+
- repo: local
166+
hooks:
167+
- id: typescript-check
168+
name: typescript-check
169+
entry: bash -c "pnpm --dir frontend run type-check"
170+
files: '.+\.ts$|.+\.vue$'
171+
# don't pass filenames else the command line sees them twice
172+
pass_filenames: false
173+
language: system
174+
# use require_serial so that script is only called once per commit
175+
require_serial: true
176+
# print the number of files as a sanity-check
177+
verbose: true
178+
179+
- repo: local
180+
hooks:
181+
- id: eslint
182+
name: eslint
183+
entry: bash -c "pnpm --dir frontend run lint"
184+
files: '.+\.ts$|.+\.vue$|.+\.js$'
185+
# don't pass filenames else the command line sees them twice
186+
pass_filenames: false
187+
language: system
188+
# use require_serial so that script is only called once per commit
189+
require_serial: true
190+
# print the number of files as a sanity-check
191+
verbose: true
192+
165193
- repo: https://github.com/Lucas-C/pre-commit-hooks-markup
166194
rev: 501f3d60cee13c712492103343bc23efdc7b3d1f #v1.0.1
167195
hooks:

template/frontend/app.config.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export default defineAppConfig({
2+
ui: {
3+
primary: "sky",
4+
gray: "cool",
5+
tooltip: {
6+
default: {
7+
openDelay: 500,
8+
},
9+
},
10+
},
11+
});

template/frontend/assets/main.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@import "tailwindcss" theme(static);
2+
@import "@nuxt/ui";

template/frontend/eslint.config.mjs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import withNuxt from "./.nuxt/eslint.config.mjs";
2+
3+
export default withNuxt(
4+
{
5+
// Disallow <script lang="js"> in Vue files
6+
files: ["**/*.vue"],
7+
rules: {
8+
"vue/block-lang": [
9+
"error",
10+
{
11+
script: {
12+
lang: "ts",
13+
},
14+
},
15+
],
16+
},
17+
},
18+
{
19+
// Disallow .js files in your source
20+
files: ["**/*.js"],
21+
ignores: [
22+
// add exceptions here if you must allow certain .js files
23+
],
24+
rules: {
25+
"no-restricted-syntax": [
26+
"error",
27+
{
28+
selector: "Program",
29+
message: "Use .ts instead of .js.",
30+
},
31+
],
32+
},
33+
},
34+
);

template/frontend/global.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// <reference types="nuxt/app" />
2+
// needed to help avoid typescript error in app.config.ts
3+
declare global {
4+
const defineAppConfig: typeof import("nuxt/app").defineAppConfig;
5+
}
6+
7+
export {};

template/frontend/layouts/default.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<template>
2+
<UApp>
3+
<NuxtPage />
4+
</UApp>
5+
</template>

template/frontend/nuxt.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// https://nuxt.com/docs/api/configuration/nuxt-config
2+
import { defineNuxtConfig } from "nuxt/config";
23
export default defineNuxtConfig({
34
compatibilityDate: "2024-11-01",
45
devtools: { enabled: true },
56
modules: ["@nuxt/eslint", "@nuxt/test-utils", "@nuxt/ui"],
7+
css: ["~/assets/css/main.css"],
68
experimental: { appManifest: false }, // https://github.com/nuxt/nuxt/issues/30461#issuecomment-2572616714
79
vite: {
810
// this seems to be explicitly needed when in a devcontainer in order for hot reloading to work

template/frontend/package.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "nuxt-app",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"type-check": "vue-tsc --noEmit",
7+
"lint": "eslint . --ext .vue,.ts,.js",
8+
"build": "pnpm run type-check && nuxt build",
9+
"dev": "nuxt dev",
10+
"generate": "nuxt generate",
11+
"preview": "nuxt preview",
12+
"postinstall": "nuxt prepare"
13+
},
14+
"dependencies": {
15+
"@nuxt/ui": "3.0.0",
16+
"nuxt": "^3.16.0",
17+
"typescript": "^5.8.2",
18+
"vue": "^3.5.13",
19+
"vue-router": "^4.5.0"
20+
},
21+
"devDependencies": {
22+
"@nuxt/eslint": "^1.2.0",
23+
"@nuxt/test-utils": "^3.17.2",
24+
"@nuxtjs/eslint-config-typescript": "^12.1.0",
25+
"autoprefixer": "^10.4.21",
26+
"eslint": "^9.22.0",
27+
"postcss": "^8.5.3",
28+
"tailwindcss": "^4.0.14",
29+
"vue-eslint-parser": "^10.1.1",
30+
"vue-tsc": "^2.2.8",
31+
"@nuxt/schema": "^3.0.0"
32+
}
33+
}

template/frontend/pages/index.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
<div>Hello World!</div>
3+
</template>

template/frontend/tsconfig.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
// https://nuxt.com/docs/guide/concepts/typescript
3+
"extends": "./.nuxt/tsconfig.json",
4+
"compilerOptions": {
5+
"target": "ESNext",
6+
"module": "ESNext",
7+
"strict": true,
8+
"moduleResolution": "node",
9+
"esModuleInterop": true,
10+
"skipLibCheck": true
11+
},
12+
"include": ["global.d.ts", "types/**/*.d.ts", "nuxt.config.ts", "app.config.ts"],
13+
"exclude": ["node_modules", ".output", ".nuxt", "dist"]
14+
}

0 commit comments

Comments
 (0)