Skip to content

Commit

Permalink
feat(create-vite): add qwik templates (#13620)
Browse files Browse the repository at this point in the history
Co-authored-by: Manu MA <manu.mtza@gmail.com>
  • Loading branch information
leifermendez and manucorporat authored Jul 6, 2023
1 parent 6d5be5c commit ef4602b
Show file tree
Hide file tree
Showing 27 changed files with 543 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/create-vite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
blue,
cyan,
green,
lightBlue,
lightGreen,
lightRed,
magenta,
Expand Down Expand Up @@ -186,6 +187,29 @@ const FRAMEWORKS: Framework[] = [
},
],
},
{
name: 'qwik',
display: 'Qwik',
color: lightBlue,
variants: [
{
name: 'qwik-ts',
display: 'TypeScript',
color: lightBlue,
},
{
name: 'qwik',
display: 'JavaScript',
color: yellow,
},
{
name: 'custom-qwik-city',
display: 'QwikCity ↗',
color: lightBlue,
customCommand: 'npm create qwik@latest basic TARGET_DIR',
},
],
},
{
name: 'others',
display: 'Others',
Expand Down
38 changes: 38 additions & 0 deletions packages/create-vite/template-qwik-ts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Qwik + Vite

## Qwik in CSR mode

This starter is using a pure CSR (Client Side Rendering) mode. This means, that the application is fully bootstrapped in the browser. Most of Qwik innovations however take advantage of SSR (Server Side Rendering) mode.

```ts
export default defineConfig({
plugins: [
qwikVite({
csr: true,
}),
],
})
```

Use `npm create qwik@latest` to create a full production ready Qwik application, using SSR and [QwikCity](https://qwik.builder.io/docs/qwikcity/), our server-side metaframwork.

## Usage

```bash
$ npm install # or pnpm install or yarn install
```

Learn more on the [Qwik Website](https://qwik.builder.io) and join our community on our [Discord](https://qwik.builder.io/chat)

## Available Scripts

In the project directory, you can run:

### `npm run dev`

Runs the app in the development mode.<br>
Open [http://localhost:5173](http://localhost:5173) to view it in the browser.

### `npm run build`

Builds the app for production to the `dist` folder.<br>
24 changes: 24 additions & 0 deletions packages/create-vite/template-qwik-ts/_gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
13 changes: 13 additions & 0 deletions packages/create-vite/template-qwik-ts/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Qwik + TS</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
18 changes: 18 additions & 0 deletions packages/create-vite/template-qwik-ts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "vite-qwik",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"devDependencies": {
"typescript": "^5.0.2",
"vite": "^4.3.9"
},
"dependencies": {
"@builder.io/qwik": "^1.2.5"
}
}
1 change: 1 addition & 0 deletions packages/create-vite/template-qwik-ts/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions packages/create-vite/template-qwik-ts/src/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#app {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}

.logo {
height: 6em;
padding: 1.5em;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.qwik:hover {
filter: drop-shadow(0 0 2em #673ab8aa);
}
.card {
padding: 2em;
}

.read-the-docs {
color: #888;
}
29 changes: 29 additions & 0 deletions packages/create-vite/template-qwik-ts/src/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { component$, useSignal } from '@builder.io/qwik'

import qwikLogo from './assets/qwik.svg'
import viteLogo from '/vite.svg'
import './app.css'

export const App = component$(() => {
const count = useSignal(0)

return (
<>
<div>
<a href="https://vitejs.dev" target="_blank">
<img src={viteLogo} class="logo" alt="Vite logo" />
</a>
<a href="https://qwik.builder.io" target="_blank">
<img src={qwikLogo} class="logo qwik" alt="Qwik logo" />
</a>
</div>
<h1>Vite + Qwik</h1>
<div class="card">
<button onClick$={() => count.value++}>count is {count.value}</button>
</div>
<p class="read-the-docs">
Click on the Vite and Qwik logos to learn more
</p>
</>
)
})
5 changes: 5 additions & 0 deletions packages/create-vite/template-qwik-ts/src/assets/qwik.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 69 additions & 0 deletions packages/create-vite/template-qwik-ts/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;

color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;

font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-text-size-adjust: 100%;
}

a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}

body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}

h1 {
font-size: 3.2em;
line-height: 1.1;
}

button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}

@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}
7 changes: 7 additions & 0 deletions packages/create-vite/template-qwik-ts/src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import '@builder.io/qwik/qwikloader.js'

import { render } from '@builder.io/qwik'
import { App } from './app.tsx'
import './index.css'

render(document.getElementById('app') as HTMLElement, <App />)
1 change: 1 addition & 0 deletions packages/create-vite/template-qwik-ts/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
26 changes: 26 additions & 0 deletions packages/create-vite/template-qwik-ts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"jsxImportSource": "@builder.io/qwik",

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
10 changes: 10 additions & 0 deletions packages/create-vite/template-qwik-ts/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}
11 changes: 11 additions & 0 deletions packages/create-vite/template-qwik-ts/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineConfig } from 'vite'
import { qwikVite } from '@builder.io/qwik/optimizer'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
qwikVite({
csr: true,
}),
],
})
38 changes: 38 additions & 0 deletions packages/create-vite/template-qwik/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Qwik + Vite

## Qwik in CSR mode

This starter is using a pure CSR (Client Side Rendering) mode. This means, that the application is fully bootstrapped in the browser. Most of Qwik innovations however take advantage of SSR (Server Side Rendering) mode.

```ts
export default defineConfig({
plugins: [
qwikVite({
csr: true,
}),
],
})
```

Use `npm create qwik@latest` to create a full production ready Qwik application, using SSR and [QwikCity](https://qwik.builder.io/docs/qwikcity/), our server-side metaframwork.

## Usage

```bash
$ npm install # or pnpm install or yarn install
```

Learn more on the [Qwik Website](https://qwik.builder.io) and join our community on our [Discord](https://qwik.builder.io/chat)

## Available Scripts

In the project directory, you can run:

### `npm run dev`

Runs the app in the development mode.<br>
Open [http://localhost:5173](http://localhost:5173) to view it in the browser.

### `npm run build`

Builds the app for production to the `dist` folder.<br>
24 changes: 24 additions & 0 deletions packages/create-vite/template-qwik/_gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
Loading

0 comments on commit ef4602b

Please sign in to comment.