mirror of
https://github.com/sajenim/javascript-template.git
synced 2025-12-29 09:46:57 +08:00
Compare commits
No commits in common. "1f1a1f347db2962227fc8117e429d0110bb13478" and "1413b1b10d770f0cdf629effc3fb6aef69d6013b" have entirely different histories.
1f1a1f347d
...
1413b1b10d
21 changed files with 193 additions and 140 deletions
17
.gitignore
vendored
17
.gitignore
vendored
|
|
@ -1,3 +1,16 @@
|
|||
# Nix
|
||||
# Dependencies
|
||||
node_modules/
|
||||
bun.lockb
|
||||
|
||||
# Build output
|
||||
dist/
|
||||
build/
|
||||
.next/
|
||||
out/
|
||||
|
||||
# TypeScript
|
||||
*.tsbuildinfo
|
||||
next-env.d.ts
|
||||
|
||||
# Direnv
|
||||
.direnv/
|
||||
result
|
||||
|
|
|
|||
27
README.md
27
README.md
|
|
@ -39,7 +39,6 @@ TypeScript template with App Router for modern web applications.
|
|||
- Next.js 15 with App Router
|
||||
- React 19
|
||||
- TypeScript
|
||||
- Tailwind CSS (utility-first styling)
|
||||
- Optimized for Vercel deployment
|
||||
|
||||
## Shared Foundation
|
||||
|
|
@ -154,8 +153,9 @@ All templates provide minimal, sensible defaults. Customize as needed:
|
|||
**Next.js:**
|
||||
|
||||
- Configure Next.js in `next.config.js`
|
||||
- Customize ESLint rules in `eslint.config.mjs`
|
||||
- Customize ESLint rules in `.eslintrc.json`
|
||||
- Adjust TypeScript settings in `tsconfig.json`
|
||||
- Extend ESLint config for stricter rules
|
||||
|
||||
**Both templates:**
|
||||
|
||||
|
|
@ -165,18 +165,17 @@ All templates provide minimal, sensible defaults. Customize as needed:
|
|||
|
||||
## Template Comparison
|
||||
|
||||
| Feature | Vanilla | Next.js |
|
||||
| ------------------ | ----------- | ----------- |
|
||||
| Framework | None | Next.js |
|
||||
| Language | JS | TS |
|
||||
| Bundler | Vite | Next.js |
|
||||
| Styling | Vanilla CSS | Tailwind v4 |
|
||||
| Client-side only | ✓ | ✗ |
|
||||
| Server-side API | ✗ | ✓ |
|
||||
| Static generation | ✓ | ✓ |
|
||||
| Type checking | ✗ | ✓ |
|
||||
| React components | ✗ | ✓ |
|
||||
| File-based routing | ✗ | ✓ |
|
||||
| Feature | Vanilla | Next.js |
|
||||
| ------------------ | ------- | ------- |
|
||||
| Framework | None | Next.js |
|
||||
| Language | JS | TS |
|
||||
| Bundler | Vite | Next.js |
|
||||
| Client-side only | ✓ | ✗ |
|
||||
| Server-side API | ✗ | ✓ |
|
||||
| Static generation | ✓ | ✓ |
|
||||
| Type checking | ✗ | ✓ |
|
||||
| React components | ✗ | ✓ |
|
||||
| File-based routing | ✗ | ✓ |
|
||||
|
||||
## Acknowledgments
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ in {
|
|||
};
|
||||
|
||||
om.templates = {
|
||||
vanilla = {
|
||||
default = {
|
||||
template = templates.default;
|
||||
params = [
|
||||
{
|
||||
|
|
|
|||
3
templates/nextjs/.eslintrc.json
Normal file
3
templates/nextjs/.eslintrc.json
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"extends": ["next/core-web-vitals", "next/typescript"]
|
||||
}
|
||||
38
templates/nextjs/.gitignore
vendored
38
templates/nextjs/.gitignore
vendored
|
|
@ -1,38 +0,0 @@
|
|||
# Dependencies
|
||||
node_modules
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Production
|
||||
build
|
||||
dist
|
||||
|
||||
# Nix
|
||||
.direnv
|
||||
result
|
||||
|
||||
# Misc
|
||||
.DS_Store
|
||||
*.pem
|
||||
*.log
|
||||
|
||||
# Debug
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# Bun
|
||||
bun.lockb
|
||||
|
||||
# Environment
|
||||
.env
|
||||
.env*.local
|
||||
|
||||
# Vercel
|
||||
.vercel
|
||||
|
||||
# TypeScript
|
||||
*.tsbuildinfo
|
||||
next-env.d.ts
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
@import "tailwindcss";
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
|
@ -9,6 +7,58 @@
|
|||
body {
|
||||
font-family: system-ui, -apple-system, sans-serif;
|
||||
line-height: 1.6;
|
||||
padding: 2rem;
|
||||
background: #f5f5f5;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
main {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
padding: 2rem;
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-bottom: 1rem;
|
||||
color: #2c3e50;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
code {
|
||||
padding: 0.2em 0.4em;
|
||||
background: #f0f0f0;
|
||||
border-radius: 3px;
|
||||
font-family: 'Monaco', 'Courier New', monospace;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
.links {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.links a {
|
||||
padding: 0.5rem 1rem;
|
||||
background: #2c3e50;
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
border-radius: 4px;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.links a:hover {
|
||||
background: #34495e;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,18 @@
|
|||
export default function Home() {
|
||||
return (
|
||||
<div className="p-8">
|
||||
<main className="max-w-3xl mx-auto p-8 bg-white rounded-lg shadow-md">
|
||||
<h1 className="mb-4 text-gray-800">Welcome to {{package-name}}</h1>
|
||||
<p className="mb-6">
|
||||
A minimal Next.js TypeScript template with App Router, powered by Bun
|
||||
and Nix.
|
||||
<main>
|
||||
<div className="container">
|
||||
<h1>Welcome to {{package-name}}</h1>
|
||||
<p>
|
||||
A minimal Next.js TypeScript template with App Router, powered by
|
||||
Bun and Nix.
|
||||
</p>
|
||||
<p className="mb-6">
|
||||
Edit <code className="px-1.5 py-0.5 bg-gray-100 rounded text-sm font-mono">app/page.tsx</code> to get started.
|
||||
</p>
|
||||
<nav className="flex gap-4 flex-wrap">
|
||||
|
||||
<div className="links">
|
||||
<a
|
||||
href="https://nextjs.org/docs"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="px-4 py-2 bg-gray-800 text-white rounded hover:bg-gray-700 transition-colors"
|
||||
>
|
||||
Next.js Docs
|
||||
</a>
|
||||
|
|
@ -23,7 +20,6 @@ export default function Home() {
|
|||
href="https://react.dev"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="px-4 py-2 bg-gray-800 text-white rounded hover:bg-gray-700 transition-colors"
|
||||
>
|
||||
React Docs
|
||||
</a>
|
||||
|
|
@ -31,12 +27,11 @@ export default function Home() {
|
|||
href="https://www.typescriptlang.org/docs"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="px-4 py-2 bg-gray-800 text-white rounded hover:bg-gray-700 transition-colors"
|
||||
>
|
||||
TypeScript Docs
|
||||
</a>
|
||||
</nav>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
import { defineConfig, globalIgnores } from 'eslint/config';
|
||||
import nextVitals from 'eslint-config-next/core-web-vitals';
|
||||
|
||||
const eslintConfig = defineConfig([
|
||||
...nextVitals,
|
||||
globalIgnores([
|
||||
'.next/**',
|
||||
'out/**',
|
||||
'build/**',
|
||||
'dist/**',
|
||||
'node_modules/**',
|
||||
'next-env.d.ts',
|
||||
]),
|
||||
]);
|
||||
|
||||
export default eslintConfig;
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
description = "Next.js TypeScript project with App Router, Bun, and Nix";
|
||||
description = "Nix templates for JavaScript projects, powered by Bun";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
|
||||
|
|
@ -12,6 +12,7 @@
|
|||
systems = import inputs.systems;
|
||||
imports = [
|
||||
./nix/modules/devshell.nix
|
||||
./nix/modules/template.nix
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
41
templates/nextjs/nix/modules/template.nix
Normal file
41
templates/nextjs/nix/modules/template.nix
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
{inputs, ...}: let
|
||||
root = inputs.self;
|
||||
in {
|
||||
flake = rec {
|
||||
templates = {
|
||||
default = {
|
||||
description = "Minimal JavaScript template with Vite and Bun";
|
||||
path = "${root}/vanilla";
|
||||
};
|
||||
|
||||
nextjs = {
|
||||
description = "Next.js TypeScript template with App Router";
|
||||
path = "${root}/nextjs";
|
||||
};
|
||||
};
|
||||
|
||||
om.templates = {
|
||||
default = {
|
||||
template = templates.default;
|
||||
params = [
|
||||
{
|
||||
name = "package-name";
|
||||
description = "Name of the JavaScript package";
|
||||
placeholder = "my-project";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
nextjs = {
|
||||
template = templates.nextjs;
|
||||
params = [
|
||||
{
|
||||
name = "package-name";
|
||||
description = "Name of the Next.js project";
|
||||
placeholder = "my-nextjs-app";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -15,14 +15,11 @@
|
|||
"react-dom": "^19.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/postcss": "^4.0.0",
|
||||
"@types/node": "^22.0.0",
|
||||
"@types/react": "^19.0.0",
|
||||
"@types/react-dom": "^19.0.0",
|
||||
"eslint": "^9.0.0",
|
||||
"eslint-config-next": "^15.0.0",
|
||||
"postcss": "^8.4.0",
|
||||
"tailwindcss": "^4.0.0",
|
||||
"typescript": "^5.6.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
export default {
|
||||
plugins: {
|
||||
'@tailwindcss/postcss': {},
|
||||
},
|
||||
};
|
||||
23
templates/vanilla/.gitignore
vendored
23
templates/vanilla/.gitignore
vendored
|
|
@ -1,23 +0,0 @@
|
|||
# Dependencies
|
||||
node_modules
|
||||
|
||||
# Build output
|
||||
dist
|
||||
build
|
||||
|
||||
# Nix
|
||||
.direnv
|
||||
result
|
||||
|
||||
# Misc
|
||||
.DS_Store
|
||||
*.log
|
||||
*.pem
|
||||
|
||||
# Bun
|
||||
bun.lockb
|
||||
|
||||
# Environment
|
||||
.env
|
||||
.env.local
|
||||
.env*.local
|
||||
|
|
@ -1,15 +1,13 @@
|
|||
import { defineConfig, globalIgnores } from 'eslint/config';
|
||||
|
||||
const eslintConfig = defineConfig([
|
||||
globalIgnores(['dist/**', 'build/**', 'node_modules/**']),
|
||||
export default [
|
||||
{
|
||||
files: ['**/*.js'],
|
||||
ignores: ["dist", "build", "node_modules"],
|
||||
},
|
||||
{
|
||||
files: ["**/*.js"],
|
||||
languageOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
ecmaVersion: "latest",
|
||||
sourceType: "module",
|
||||
},
|
||||
rules: {},
|
||||
},
|
||||
]);
|
||||
|
||||
export default eslintConfig;
|
||||
];
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
description = "Vanilla JavaScript project with Vite, Bun, and Nix";
|
||||
description = "Nix templates for JavaScript projects, powered by Bun";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
|
||||
|
|
@ -12,6 +12,7 @@
|
|||
systems = import inputs.systems;
|
||||
imports = [
|
||||
./nix/modules/devshell.nix
|
||||
./nix/modules/template.nix
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{package-name}}</title>
|
||||
<title>JavaScript App</title>
|
||||
<link rel="stylesheet" href="src/style.css">
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ in {
|
|||
[
|
||||
bun
|
||||
nodejs
|
||||
typescript
|
||||
eslint
|
||||
just
|
||||
prettierd
|
||||
|
|
|
|||
41
templates/vanilla/nix/modules/template.nix
Normal file
41
templates/vanilla/nix/modules/template.nix
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
{inputs, ...}: let
|
||||
root = inputs.self;
|
||||
in {
|
||||
flake = rec {
|
||||
templates = {
|
||||
default = {
|
||||
description = "Minimal JavaScript template with Vite and Bun";
|
||||
path = "${root}/vanilla";
|
||||
};
|
||||
|
||||
nextjs = {
|
||||
description = "Next.js TypeScript template with App Router";
|
||||
path = "${root}/nextjs";
|
||||
};
|
||||
};
|
||||
|
||||
om.templates = {
|
||||
default = {
|
||||
template = templates.default;
|
||||
params = [
|
||||
{
|
||||
name = "package-name";
|
||||
description = "Name of the JavaScript package";
|
||||
placeholder = "my-project";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
nextjs = {
|
||||
template = templates.nextjs;
|
||||
params = [
|
||||
{
|
||||
name = "package-name";
|
||||
description = "Name of the Next.js project";
|
||||
placeholder = "my-nextjs-app";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "{{package-name}}",
|
||||
"name": "javascript-template",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
const app = document.getElementById("app");
|
||||
|
||||
app.innerHTML = `
|
||||
<h1>Welcome to {{package-name}}</h1>
|
||||
<p>A minimal JavaScript template with Vite, powered by Bun and Nix.</p>
|
||||
<h1>JavaScript Template</h1>
|
||||
<p>Edit <code>src/main.js</code> to get started.</p>
|
||||
`;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,10 +26,6 @@ h1 {
|
|||
color: #2c3e50;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
code {
|
||||
padding: 0.2em 0.4em;
|
||||
background: #f0f0f0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue