Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vite #409

Merged
merged 18 commits into from
Mar 2, 2021
Merged

Vite #409

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
------
---

Before filing an issue we'd appreciate it if you could take a moment to ensure
there isn't already an open issue or pull-request.
-----

---

If there's an existing issue, please add a :+1: reaction to the description of
the issue. One way we prioritize issues is by the number of :+1: reactions on
their descriptions. Please DO NOT add `+1` or :+1: comments.

### Feature requests and proposals

We're excited to hear how we can make SvelteKit better. Please add as much detail
as you can on your use case. To propose an implementation of a large feature or
change, please create an [RFC](https://github.com/sveltejs/rfcs).

### Bugs

If you're filing an issue about a bug please include as much information
as you can, including the following.

- The output of `npx envinfo --system --npmPackages svelte,@sveltejs/kit,@sveltejs/snowpack-config --binaries --browsers`
- The output of `npx envinfo --system --npmPackages svelte,@sveltejs/kit --binaries --browsers`
- Your browser
- Your adapter (e.g. Node, static, Vercel, Begin, etc...)

- *Repeatable steps to reproduce the issue*
- _Repeatable steps to reproduce the issue_

* We recommend creating a small repo that illustrates the problem.
* Reproductions should be small, self-contained, correct examples – http://sscce.org.

Thanks for being part of SvelteKit!
-------
## Thanks for being part of SvelteKit!
12 changes: 6 additions & 6 deletions documentation/docs/01-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ If you take a look inside a new SvelteKit project, you'll see some files that Sv
│ └ app.html
├ static
│ ├ # your files here
snowpack.config.cjs
svelte.config.cjs
svelte.config.cjs
vite.config.js
```

### package.json
Expand Down Expand Up @@ -73,10 +73,10 @@ Sapper doesn't serve these files — you'd typically use [sirv](https://github.c

> Note that the default behaviour of the service worker is to cache all assets from the static directory, so if you have more than 50mb of files here, you will start to exceed the cache limit for service-workers in some browsers, which can cause the service worker to stop loading. In this instance, it is advisable to customise what files are cached by editing the service-worker yourself.

### snowpack.config.cjs

This is the [Snowpack configuration file](https://www.snowpack.dev/reference/configuration) for your project.

### svelte.config.cjs

This file contains SvelteKit options as well as options for `svelte-preprocess`.

### vite.config.js

This is the [Vite configuration file](https://vitejs.dev/config/) for your project.
1 change: 0 additions & 1 deletion examples/hn.svelte.dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"devDependencies": {
"@sveltejs/adapter-netlify": "workspace:*",
"@sveltejs/kit": "workspace:*",
"@sveltejs/snowpack-config": "workspace:*",
"svelte": "^3.32.1"
}
}
10 changes: 0 additions & 10 deletions examples/hn.svelte.dev/snowpack.config.cjs

This file was deleted.

12 changes: 6 additions & 6 deletions examples/hn.svelte.dev/src/components/Nav.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<img alt="Svelte Hacker News logo" class="icon" src="/favicon.png">

<ul>
<li><a rel="prefetch" href="/top/1" class:selected={section === "top"}>top</a></li>
<li><a rel="prefetch" href="/new/1" class:selected={section === "new"}>new</a></li>
<li><a rel="prefetch" href="/show/1" class:selected={section === "show"}>show</a></li>
<li><a rel="prefetch" href="/ask/1" class:selected={section === "ask"}>ask</a></li>
<li><a rel="prefetch" href="/jobs/1" class:selected={section === "jobs"}>jobs</a></li>
<li><a sveltekit:prefetch href="/top/1" class:selected={section === "top"}>top</a></li>
<li><a sveltekit:prefetch href="/new/1" class:selected={section === "new"}>new</a></li>
<li><a sveltekit:prefetch href="/show/1" class:selected={section === "show"}>show</a></li>
<li><a sveltekit:prefetch href="/ask/1" class:selected={section === "ask"}>ask</a></li>
<li><a sveltekit:prefetch href="/jobs/1" class:selected={section === "jobs"}>jobs</a></li>

<li class="about"><a rel="prefetch" href="/about" class:selected={section === "about"}>about</a></li>
<li class="about"><a sveltekit:prefetch href="/about" class:selected={section === "about"}>about</a></li>
</ul>
</nav>

Expand Down
3 changes: 2 additions & 1 deletion examples/hn.svelte.dev/src/routes/$error.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<script>
import { dev } from '$app/env';

export let status;
export let error;

const dev = process.env.NODE_ENV === 'development';
const offline = typeof navigator !== 'undefined' && navigator.onLine === false;

const title = offline ? 'Offline' : status;
Expand Down
4 changes: 2 additions & 2 deletions examples/hn.svelte.dev/src/routes/[list]/_ItemSummary.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
{:else}
<p>
{item.points} points by
<a rel="prefetch" href="/user/{item.user}">{item.user}</a> {item.time_ago}
| <a rel="prefetch" href="/item/{item.id}">{item.comments_count} {item.comments_count === 1 ? 'comment' : 'comments'}</a>
<a sveltekit:prefetch href="/user/{item.user}">{item.user}</a> {item.time_ago}
| <a sveltekit:prefetch href="/item/{item.id}">{item.comments_count} {item.comments_count === 1 ? 'comment' : 'comments'}</a>
</p>
{/if}

Expand Down
6 changes: 3 additions & 3 deletions examples/hn.svelte.dev/src/routes/item/_Comment.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{#if !comment.deleted}
<article class="comment" class:hidden>
<div class="meta-bar" on:click="{() => hidden = !hidden}">
<span class="meta"><a rel="prefetch" href="/user/{comment.user}">{comment.user}</a> {comment.time_ago}</span>
<span class="meta"><a sveltekit:prefetch href="/user/{comment.user}">{comment.user}</a> {comment.time_ago}</span>
</div>

<div class="body">
Expand Down Expand Up @@ -36,12 +36,12 @@
.meta-bar {
padding: 1em 0;
cursor: pointer;
background: 100% 50% no-repeat url(/icons/fold.svg);
background: 100% 50% no-repeat url(./_icons/fold.svg);
background-size: 1em 1em;
}

.hidden .meta-bar {
background-image: url(/icons/unfold.svg);
background-image: url(./_icons/unfold.svg);
}

.comment .children {
Expand Down
9 changes: 9 additions & 0 deletions examples/hn.svelte.dev/vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { resolve } from 'path';

export default {
resolve: {
alias: {
$components: resolve('src/components')
}
}
};
1 change: 0 additions & 1 deletion examples/realworld.svelte.dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"devDependencies": {
"@sveltejs/adapter-node": "workspace:*",
"@sveltejs/kit": "workspace:*",
"@sveltejs/snowpack-config": "workspace:*",
"marked": "^1.2.8",
"svelte": "^3.32.1"
},
Expand Down
15 changes: 0 additions & 15 deletions examples/realworld.svelte.dev/snowpack.config.cjs

This file was deleted.

3 changes: 1 addition & 2 deletions examples/realworld.svelte.dev/src/routes/$error.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<script>
import { dev } from '$app/env';
import Layout from './$layout.svelte';

export let error, status;

let dev = import.meta.env.MODE === 'development';
</script>

<svelte:head>
Expand Down
10 changes: 10 additions & 0 deletions examples/realworld.svelte.dev/vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { resolve } from 'path';

export default {
resolve: {
alias: {
$common: resolve('src/common'),
$components: resolve('src/components')
}
}
};
1 change: 0 additions & 1 deletion examples/sandbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"devDependencies": {
"@sveltejs/adapter-node": "workspace:*",
"@sveltejs/kit": "workspace:*",
"@sveltejs/snowpack-config": "workspace:*",
"svelte": "^3.32.1"
}
}
10 changes: 0 additions & 10 deletions examples/sandbox/snowpack.config.cjs

This file was deleted.

9 changes: 9 additions & 0 deletions examples/sandbox/vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { resolve } from 'path';

export default {
resolve: {
alias: {
$components: resolve('src/components')
}
}
};
1 change: 0 additions & 1 deletion examples/svelte-kit-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"@sveltejs/adapter-node": "workspace:*",
"@sveltejs/adapter-static": "workspace:*",
"@sveltejs/kit": "workspace:*",
"@sveltejs/snowpack-config": "workspace:*",
"svelte": "^3.32.1"
}
}
10 changes: 0 additions & 10 deletions examples/svelte-kit-demo/snowpack.config.cjs

This file was deleted.

6 changes: 3 additions & 3 deletions examples/svelte-kit-demo/src/components/Nav.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
</script>

<nav>
<a href="/" rel="prefetch" class:active={path === '/'}>home</a>
<a href="/about" rel="prefetch" class:active={path === '/about'}>about</a>
<a href="/blog" rel="prefetch" class:active={path === '/blog'}>blog</a>
<a href="/" sveltekit:prefetch class:active={path === '/'}>home</a>
<a href="/about" sveltekit:prefetch class:active={path === '/about'}>about</a>
<a href="/blog" sveltekit:prefetch class:active={path === '/blog'}>blog</a>
</nav>

<style>
Expand Down
9 changes: 9 additions & 0 deletions examples/svelte-kit-demo/vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { resolve } from 'path';

export default {
resolve: {
alias: {
$components: resolve('src/components')
}
}
};
4 changes: 0 additions & 4 deletions packages/app-utils/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
.DS_Store
node_modules

/files
/http
/renderer
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as fs from 'fs';
import * as path from 'path';
import fs from 'fs';
import path from 'path';

export function mkdirp(dir) {
try {
Expand All @@ -10,6 +10,10 @@ export function mkdirp(dir) {
}
}

export function rimraf(path) {
(fs.rmSync || fs.rmdirSync)(path, { recursive: true, force: true });
}

export function copy(from, to, filter = () => true) {
if (!filter(path.basename(from))) return [];

Expand Down
File renamed without changes.
7 changes: 1 addition & 6 deletions packages/app-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@
"name": "@sveltejs/app-utils",
"version": "1.0.0-next.1",
"scripts": {
"clean": "node rimraf.js files http renderer",
"dev": "npm run clean && rollup -cw",
"build": "npm run clean && rollup -c",
"lint": "eslint --ignore-path .gitignore \"**/*.{ts,js,svelte}\" && npm run check-format",
"format": "prettier --write . --config ../../.prettierrc --ignore-path .gitignore",
"check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore",
"prepublishOnly": "npm run build",
"test": "uvu"
},
"dependencies": {
Expand All @@ -34,7 +30,6 @@
},
"files": [
"files",
"http",
"renderer"
"http"
]
}
11 changes: 0 additions & 11 deletions packages/app-utils/rimraf.js

This file was deleted.

20 changes: 0 additions & 20 deletions packages/app-utils/rollup.config.js

This file was deleted.

6 changes: 3 additions & 3 deletions packages/create-svelte/cli/modifications/add_css.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { bold, green } from 'kleur/colors';
import { add_svelte_prepocess_to_config, update_component, update_package_json } from './utils';
import { add_svelte_preprocess_to_config, update_component, update_package_json } from './utils';

export default async function add_css(cwd, which) {
if (which === 'css') {
Expand All @@ -11,7 +11,7 @@ export default async function add_css(cwd, which) {
});
update_component(cwd, 'src/components/Counter.svelte', [['<style>', '<style lang="less">']]);
update_component(cwd, 'src/routes/index.svelte', [['<style>', '<style lang="less">']]);
add_svelte_prepocess_to_config(cwd);
add_svelte_preprocess_to_config(cwd);
console.log(
bold(
green(
Expand All @@ -27,7 +27,7 @@ export default async function add_css(cwd, which) {
});
update_component(cwd, 'src/components/Counter.svelte', [['<style>', '<style lang="scss">']]);
update_component(cwd, 'src/routes/index.svelte', [['<style>', '<style lang="scss">']]);
add_svelte_prepocess_to_config(cwd);
add_svelte_preprocess_to_config(cwd);
console.log(
bold(
green(
Expand Down
Loading