Skip to content

Commit 9c4c20e

Browse files
authored
refactor: split resolve options phase (#229)
1 parent 3a38b77 commit 9c4c20e

File tree

15 files changed

+224
-103
lines changed

15 files changed

+224
-103
lines changed

.changeset/khaki-kids-vanish.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/vite-plugin-svelte': minor
3+
---
4+
5+
handle preprocess for prebundleSvelteLibraries

.changeset/olive-flowers-glow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/vite-plugin-svelte': patch
3+
---
4+
5+
handle production builds for non "production" mode

packages/e2e-tests/env/.env.staging

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
NODE_ENV=production

packages/e2e-tests/env/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# default svelte app template
2+
3+
Created with `npx degit sveltejs/template`
4+
5+
adapted to vite by moving index.html to root and replacing rollup config with vite
6+
7+
use pnpm
8+
9+
`pnpm dev` starts dev server
10+
`pnpm build` builds for production
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { findAssetFile, isBuild } from 'testUtils';
2+
3+
// can't have no tests for test:serve
4+
it('dummy', () => {});
5+
6+
if (isBuild) {
7+
it('custom production mode should build for production', () => {
8+
const indexBundle = findAssetFile(/index\..*\.js/);
9+
expect(indexBundle).not.toContain('SvelteComponentDev');
10+
});
11+
}

packages/e2e-tests/env/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width,initial-scale=1" />
6+
7+
<title>Svelte app</title>
8+
9+
<script type="module" src="/src/main.js"></script>
10+
</head>
11+
12+
<body></body>
13+
</html>

packages/e2e-tests/env/package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "e2e-tests-env",
3+
"private": true,
4+
"version": "1.0.0",
5+
"scripts": {
6+
"dev": "vite",
7+
"build": "vite build",
8+
"preview": "vite preview"
9+
},
10+
"devDependencies": {
11+
"@sveltejs/vite-plugin-svelte": "workspace:*",
12+
"svelte": "^3.44.2",
13+
"vite": "^2.7.0"
14+
},
15+
"type": "module"
16+
}

packages/e2e-tests/env/src/App.svelte

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<h1>Hello world!</h1>
2+
3+
<style>
4+
h1 {
5+
color: #ff3e00;
6+
}
7+
</style>

packages/e2e-tests/env/src/main.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import App from './App.svelte';
2+
3+
const app = new App({
4+
target: document.body
5+
});
6+
7+
export default app;

packages/e2e-tests/env/vite.config.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { svelte } from '@sveltejs/vite-plugin-svelte';
2+
import { defineConfig } from 'vite';
3+
4+
export default defineConfig({
5+
mode: 'staging',
6+
plugins: [svelte()],
7+
build: {
8+
// make build faster by skipping transforms and minification
9+
target: 'esnext',
10+
minify: false,
11+
commonjsOptions: {
12+
// pnpm only symlinks packages, and vite wont process cjs deps not in
13+
// node_modules, so we add the cjs dep here
14+
include: [/node_modules/, /cjs-only/]
15+
}
16+
},
17+
server: {
18+
watch: {
19+
// During tests we edit the files too fast and sometimes chokidar
20+
// misses change events, so enforce polling for consistency
21+
usePolling: true,
22+
interval: 100
23+
}
24+
}
25+
});

0 commit comments

Comments
 (0)