diff --git a/packages/playground/ssr-vue/__tests__/ssr-vue.spec.ts b/packages/playground/ssr-vue/__tests__/ssr-vue.spec.ts index 6ed0f14567add5..567396ba1674ca 100644 --- a/packages/playground/ssr-vue/__tests__/ssr-vue.spec.ts +++ b/packages/playground/ssr-vue/__tests__/ssr-vue.spec.ts @@ -13,7 +13,6 @@ test('vuex can be import succeed by named import', async () => { expect(storeHtml).toMatch('bar') }) - test('/about', async () => { await page.goto(url + '/about') expect(await page.textContent('h1')).toMatch('About') diff --git a/packages/playground/tailwind/vite.config.ts b/packages/playground/tailwind/vite.config.ts index 46c8a997bdc912..e7c50bf3c3ae78 100644 --- a/packages/playground/tailwind/vite.config.ts +++ b/packages/playground/tailwind/vite.config.ts @@ -15,6 +15,6 @@ export default defineConfig({ server: { // This option caused issues with HMR, // although it should not affect the build - origin: "http://localhost:8080/", + origin: 'http://localhost:8080/' } }) diff --git a/packages/plugin-react/src/index.ts b/packages/plugin-react/src/index.ts index 134df5fcb1db57..98682d347726ac 100644 --- a/packages/plugin-react/src/index.ts +++ b/packages/plugin-react/src/index.ts @@ -113,7 +113,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] { const isProjectFile = !isNodeModules && (id[0] === '\0' || id.startsWith(projectRoot + '/')) - let plugins = isProjectFile ? [...userPlugins] : [] + const plugins = isProjectFile ? [...userPlugins] : [] let useFastRefresh = false if (!skipFastRefresh && !ssr && !isNodeModules) { diff --git a/packages/plugin-vue/src/index.ts b/packages/plugin-vue/src/index.ts index 01a27ea9959beb..71ec6e7a4bef47 100644 --- a/packages/plugin-vue/src/index.ts +++ b/packages/plugin-vue/src/index.ts @@ -90,7 +90,7 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin { ? createFilter(/\.(j|t)sx?$/, /node_modules/) : createFilter(refTransform) - // compat for older verisons + // compat for older versions const canUseRefTransform = typeof compiler.shouldTransformRef === 'function' let options: ResolvedOptions = { diff --git a/packages/vite/src/node/__tests__/build.spec.ts b/packages/vite/src/node/__tests__/build.spec.ts index 34d80736a5b430..64f9dbe22ae2e7 100644 --- a/packages/vite/src/node/__tests__/build.spec.ts +++ b/packages/vite/src/node/__tests__/build.spec.ts @@ -69,40 +69,56 @@ describe('resolveLibFilename', () => { describe('resolveBuildOptions', () => { test('resolve build.rollupOptions.input', async () => { - const config = await resolveConfig({ - build: { - rollupOptions: { - input: 'index.html' + const config = await resolveConfig( + { + build: { + rollupOptions: { + input: 'index.html' + } } - } - }, 'build', 'production') + }, + 'build', + 'production' + ) expect(config.build.rollupOptions.input).toBe(resolve('index.html')) }) test('resolve build.rollupOptions.input{}', async () => { - const config = await resolveConfig({ - build: { - rollupOptions: { - input: { - index: 'index.html' + const config = await resolveConfig( + { + build: { + rollupOptions: { + input: { + index: 'index.html' + } } } - } - }, 'build', 'production') + }, + 'build', + 'production' + ) - expect(config.build.rollupOptions.input['index']).toBe(resolve('index.html')) + expect(config.build.rollupOptions.input['index']).toBe( + resolve('index.html') + ) }) test('resolve build.rollupOptions.input[]', async () => { - const config = await resolveConfig({ - build: { - rollupOptions: { - input: ['index.html'] + const config = await resolveConfig( + { + build: { + rollupOptions: { + input: ['index.html'] + } } - } - }, 'build', 'production') + }, + 'build', + 'production' + ) - expect(config.build.rollupOptions.input).toStrictEqual([resolve('index.html')]) + expect(config.build.rollupOptions.input).toStrictEqual([ + resolve('index.html') + ]) }) test('resolve index.html', async () => { @@ -112,7 +128,11 @@ describe('resolveBuildOptions', () => { }) test('resolve build.outdir', async () => { - const config = await resolveConfig({ build: { outDir: 'outDir' } }, 'build', 'production') + const config = await resolveConfig( + { build: { outDir: 'outDir' } }, + 'build', + 'production' + ) expect(config.build.outDir).toBe(resolve('outDir')) }) @@ -124,13 +144,21 @@ describe('resolveBuildOptions', () => { }) test('resolve build.lib.entry', async () => { - const config = await resolveConfig({ build: { lib: { entry: 'index.html' } } }, 'build', 'production') + const config = await resolveConfig( + { build: { lib: { entry: 'index.html' } } }, + 'build', + 'production' + ) expect(config.build.rollupOptions.input).toBe(resolve('index.html')) }) test('resolve build.ssr', async () => { - const config = await resolveConfig({ build: { ssr: 'ssr.ts' } }, 'build', 'production') + const config = await resolveConfig( + { build: { ssr: 'ssr.ts' } }, + 'build', + 'production' + ) expect(config.build.rollupOptions.input).toBe(resolve('ssr.ts')) }) diff --git a/packages/vite/src/node/build.ts b/packages/vite/src/node/build.ts index 76809b0af7a0ff..3a72a666ff4752 100644 --- a/packages/vite/src/node/build.ts +++ b/packages/vite/src/node/build.ts @@ -233,7 +233,10 @@ export type ResolvedBuildOptions = Required< > > -export function resolveBuildOptions(root: string, raw?: BuildOptions): ResolvedBuildOptions { +export function resolveBuildOptions( + root: string, + raw?: BuildOptions +): ResolvedBuildOptions { const resolved: ResolvedBuildOptions = { target: 'modules', polyfillModulePreload: true, @@ -269,7 +272,8 @@ export function resolveBuildOptions(root: string, raw?: BuildOptions): ResolvedB } } - const resolve = (p: string) => p.startsWith('\0') ? p : path.resolve(root, p) + const resolve = (p: string) => + p.startsWith('\0') ? p : path.resolve(root, p) resolved.outDir = resolve(resolved.outDir) @@ -277,10 +281,13 @@ export function resolveBuildOptions(root: string, raw?: BuildOptions): ResolvedB if (raw?.rollupOptions?.input) { input = Array.isArray(raw.rollupOptions.input) - ? raw.rollupOptions.input.map(input => resolve(input)) + ? raw.rollupOptions.input.map((input) => resolve(input)) : typeof raw.rollupOptions.input === 'object' ? Object.fromEntries( - Object.entries(raw.rollupOptions.input).map(([key, value]) => [key, resolve(value)]) + Object.entries(raw.rollupOptions.input).map(([key, value]) => [ + key, + resolve(value) + ]) ) : resolve(raw.rollupOptions.input) } else { diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 388ffc04452126..a7cd3fd6cc11fa 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -218,7 +218,10 @@ export function cssPlugin(config: ResolvedConfig): Plugin { : await moduleGraph.ensureEntryFromUrl( ( await fileToUrl(file, config, this) - ).replace((config.server?.origin ?? '') + config.base, '/') + ).replace( + (config.server?.origin ?? '') + config.base, + '/' + ) ) ) }