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

refactor dev to use vite server #2494

Merged
merged 1 commit into from
Jan 31, 2022
Merged
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
refactor dev to use vite server
  • Loading branch information
FredKSchott committed Jan 29, 2022
commit f46afa98c648e9ea7a44978c79e4f8b99f404fcd
7 changes: 7 additions & 0 deletions .changeset/empty-snails-allow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'astro': minor
---

Refactor dev server to use vite server internally.

This should be an invisible change, and no breaking changes are expected from this change. However, it is a big enough refactor that some unexpected changes may occur. If you've experienced a regression in the dev server, it is most likely a bug!
3 changes: 1 addition & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI


"""
This license applies to parts of the `packages/create-astro` subdirectory originating from the
https://github.com/sveltejs/kit repository:
This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/sveltejs/kit repository:

Copyright (c) 2020 [these people](https://github.com/sveltejs/kit/graphs/contributors)

Expand Down
1 change: 0 additions & 1 deletion packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
"astring": "^1.7.5",
"ci-info": "^3.2.0",
"common-ancestor-path": "^1.0.1",
"connect": "^3.7.0",
"eol": "^0.9.1",
"es-module-lexer": "^0.9.3",
"esbuild": "0.13.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/cli/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-console */

import type { AstroConfig } from '../@types/astro';
import type { LogOptions } from '../core/logger';
import type { LogOptions } from '../core/logger.js';

import * as colors from 'kleur/colors';
import fs from 'fs';
Expand Down
12 changes: 6 additions & 6 deletions packages/astro/src/core/create-vite.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { AstroConfig } from '../@types/astro';
import type { AstroDevServer } from './dev';
import type { LogOptions } from './logger';

import { builtinModules } from 'module';
import { fileURLToPath } from 'url';
import vite from './vite.js';
import astroVitePlugin from '../vite-plugin-astro/index.js';
import astroViteServerPlugin from '../vite-plugin-astro-server/index.js';
import astroPostprocessVitePlugin from '../vite-plugin-astro-postprocess/index.js';
import configAliasVitePlugin from '../vite-plugin-config-alias/index.js';
import markdownVitePlugin from '../vite-plugin-markdown/index.js';
Expand Down Expand Up @@ -34,12 +34,11 @@ export type ViteConfigWithSSR = vite.InlineConfig & { ssr?: { external?: string[

interface CreateViteOptions {
astroConfig: AstroConfig;
devServer?: AstroDevServer;
logging: LogOptions;
}

/** Return a common starting point for all Vite actions */
export async function createVite(inlineConfig: ViteConfigWithSSR, { astroConfig, logging, devServer }: CreateViteOptions): Promise<ViteConfigWithSSR> {
export async function createVite(inlineConfig: ViteConfigWithSSR, { astroConfig, logging }: CreateViteOptions): Promise<ViteConfigWithSSR> {
// First, start with the Vite configuration that Astro core needs
let viteConfig: ViteConfigWithSSR = {
cacheDir: fileURLToPath(new URL('./node_modules/.vite/', astroConfig.projectRoot)), // using local caches allows Astro to be used in monorepos, etc.
Expand All @@ -50,10 +49,11 @@ export async function createVite(inlineConfig: ViteConfigWithSSR, { astroConfig,
},
plugins: [
configAliasVitePlugin({ config: astroConfig }),
astroVitePlugin({ config: astroConfig, devServer, logging }),
markdownVitePlugin({ config: astroConfig, devServer }),
astroVitePlugin({ config: astroConfig, logging }),
astroViteServerPlugin({ config: astroConfig, logging }),
markdownVitePlugin({ config: astroConfig }),
jsxVitePlugin({ config: astroConfig, logging }),
astroPostprocessVitePlugin({ config: astroConfig, devServer }),
astroPostprocessVitePlugin({ config: astroConfig }),
],
publicDir: fileURLToPath(astroConfig.public),
root: fileURLToPath(astroConfig.projectRoot),
Expand Down
Loading