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

feat: expose isFileServingAllowed as public utility #12894

Merged
merged 2 commits into from
Apr 18, 2023
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
3 changes: 1 addition & 2 deletions packages/vite/src/node/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ import type {
TransformResult,
} from 'rollup'
export type { PluginContext } from 'rollup'
import type { UserConfig } from './config'
import type { ConfigEnv, ResolvedConfig, UserConfig } from './config'
import type { ServerHook } from './server'
import type { IndexHtmlTransform } from './plugins/html'
import type { ModuleNode } from './server/moduleGraph'
import type { HmrContext } from './server/hmr'
import type { PreviewServerHook } from './preview'
import type { ConfigEnv, ResolvedConfig } from './'

/**
* Vite plugins extends the Rollup plugin interface with a few extra
Expand Down
5 changes: 3 additions & 2 deletions packages/vite/src/node/plugins/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import {
generateCodeFrame,
timeFrom,
} from '../utils'
import type { ResolvedConfig, ViteDevServer } from '..'
import type { ViteDevServer } from '../server'
import type { ResolvedConfig } from '../config'
import type { Plugin } from '../plugin'
import { searchForWorkspaceRoot } from '..'
import { searchForWorkspaceRoot } from '../server/searchRoot'

const debug = createDebugger('vite:esbuild')

Expand Down
1 change: 1 addition & 0 deletions packages/vite/src/node/publicUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ export { normalizePath, mergeConfig, mergeAlias, createFilter } from './utils'
export { send } from './server/send'
export { createLogger } from './logger'
export { searchForWorkspaceRoot } from './server/searchRoot'
export { isFileServingAllowed } from './server/middlewares/static'
export { loadEnv, resolveEnvPrefix } from './env'
2 changes: 0 additions & 2 deletions packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ import type { TransformOptions, TransformResult } from './transformRequest'
import { transformRequest } from './transformRequest'
import { searchForWorkspaceRoot } from './searchRoot'

export { searchForWorkspaceRoot } from './searchRoot'

export interface ServerOptions extends CommonServerOptions {
/**
* Configure HMR-specific options (port, host, path & protocol)
Expand Down
3 changes: 3 additions & 0 deletions packages/vite/src/node/server/middlewares/static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ export function serveRawFsMiddleware(
}
}

/**
* Check if the url is allowed to be served, via the `server.fs` config.
*/
export function isFileServingAllowed(
url: string,
server: ViteDevServer,
Expand Down