UNPKG

@netlify/build-info

Version:
386 lines (385 loc) 12.8 kB
/** * Directory to change to before starting a build. This is where we will look for package.json/.nvmrc/etc. If not set, defaults to the root directory. */ export type BasePath = string; /** * Default build command. */ export type BuildCommand = string; /** * Custom directory to look for edge functions. If not set, defaults to `netlify/edge-functions/` */ export type EdgeFunctionsDirectory = string; /** * Skip all post processing, ignoring any other settings. */ export type SkipProcessing = boolean; /** * Concatenate consecutive CSS files together to reduce HTTP requests. */ export type BundleCSS = boolean; /** * Run CSS through a minifier to reduce file size. */ export type MinifyCSS = boolean; /** * Concatenate consecutive JS files together to reduce HTTP requests. */ export type BundleJS = boolean; /** * Run JS through a minifier to reduce file size. */ export type MinifyJS = boolean; /** * Rewrite link URLs to pretty URLs (/about.html -> /about, /about/index.html -> /about/) */ export type PrettyURLs = boolean; /** * Run all images through lossless image compression. */ export type CompressImages = boolean; /** * Directory that contains the deploy-ready HTML files and assets generated by the build. This is relative to the base directory if one has been set, or the root directory if a base has not been set. */ export type PublishPath = string; export type Plugins = BuildPlugins[]; /** * The path you want to redirect. */ export type From = string; /** * The URL or path you want to redirect to. */ export type To = string; /** * The HTTP status code you want to use in that redirect; 301 by default. */ export type HTTPStatusCode = number; /** * Whether to override any existing content in the path or not; false by default. */ export type Force = boolean; /** * Cookie-based redirects allow you to send visitors content based on whether a specific HTTP cookie exists in the request or not, regardless of its value. This condition checks the cookie name in a case-insensitive way. */ export type CookiePresence = string[]; /** * The Country attribute accepts ISO 3166-1 alpha-2 country codes. */ export type Country = string[]; /** * The Language attribute accepts standard browser language identification codes and locale codes that combine language and country. */ export type Language = string[]; /** * Role-based redirects let you restrict access to certain paths of your application to logged-in visitors with certain roles, as authorized by Netlify Identity or any authentication provider that supports JSON Web Tokens (JWT). */ export type Role = string[]; /** * Name of an environment variable for signed proxy redirects. */ export type Signed = string; /** * Define which paths this specific headers block will cover. */ export type For = string; /** * Relative path to an import map file to map module URLs to names. */ export type ImportMaps = string; /** * List of Node.js modules that are copied to the bundled artifact without adjusting their source or references during the bundling process; only applies when `node_bundler` is set to `esbuild`. This property helps handle dependencies that can't be inlined, such as modules with native add-ons. */ export type ExternalNodeModules = string[]; /** * list of additional paths to include in the function bundle. Although our build system includes statically referenced files (like `require("./some-file.js")`) by default, `included_files` lets you specify additional files or directories and reference them dynamically in function code. You can use `*` to match any character or prefix an entry with `!` to exclude files. Paths are relative to the base directory. */ export type IncludedFiles = string[]; /** * Function bundling method used in `@netlify/zip-it-and-ship-it`. */ export type NodeBundler = 'zisi' | 'esbuild' | 'nft' | 'none'; /** * Custom path to your functions. The default location is `YOUR_BASE_DIRECTORY/netlify/functions`. */ export type Directory = string; /** * A command that starts your development server or runs a command such as a compiler watch in the background. If no `targetPort` is specified, it runs the command in the background in addition to the static file server. */ export type DevCommand = string; /** * The port that Netlify Dev is accessible from in the browser. */ export type Port = number; /** * port for your application server, framework, or site generator. If provided, the CLI will wait until the provided `targetPort` is reachable and then proxy requests to it. If you specify values for both `command` and `targetPort`, `framework` must be `#custom`. */ export type TargetPort = number; /** * The port where Netlify Dev serves functions. */ export type FunctionsPort = number; /** * Path to your static content folder. */ export type PublishPath1 = string; /** * Object path that points to role values for JWT-based redirects. */ export type JWTRolePath = string; /** * Secret used to verify tokens for JWT-based redirects. */ export type JWTSecret = string; /** * Boolean value that determines whether Netlify Dev launches the local server address in your browser. */ export type PublishPath2 = boolean; /** * Setting to use if a project is detected incorrectly, flagged by multiple detectors, or requires a `command` and `targetPort`. */ export type PublishPath3 = '#auto' | '#static' | '#custom'; /** * Path to the certificate file. */ export type CertificateFile = string; /** * Path to the private key file. */ export type PrivateKeyFile = string; /** * Config file for Netlify */ export type NetlifyTOML = { build?: BuildSettings; plugins?: Plugins; template?: string; context?: { production?: ProductionContext; 'deploy-preview'?: DeployPreviewContext; 'branch-deploy'?: BranchDeployContext; } & Record<string, SpecificBranchContext>; redirects?: Redirects[]; headers?: Headers[]; functions?: Functions; edge_functions?: EdgeFunctions[]; dev?: NetlifyDev; }; /** * Settings in the [build] context are global and are applied to all contexts unless otherwise overridden by more specific contexts. */ export type BuildSettings = { base?: BasePath; command?: BuildCommand; edge_functions?: EdgeFunctionsDirectory; environment?: EnvironmentVariables; processing?: PostProcessing; publish?: PublishPath; functions?: string; }; /** * Define environment variables. Be mindful when using this option and avoid committing sensitive values to public source repositories. */ export type EnvironmentVariables = Record<string, unknown>; /** * You can manage post processing settings with the processing property. These settings override corresponding settings under `Site settings > Build & deploy > Post processing > Asset Optimization`. * * When declaring post processing settings, you can use the `processing` property on `build` to define settings for each post processing option. Note that `skip_processing` must be set to `false` for any other settings to take effect. */ export type PostProcessing = { skip_processing?: SkipProcessing; css?: CSS; js?: JS; html?: HTML; images?: Images; }; /** * Processing settings for CSS files. */ export type CSS = { bundle?: BundleCSS; minify?: MinifyCSS; }; /** * Processing settings for JavaScript files. */ export type JS = { bundle?: BundleJS; minify?: MinifyJS; }; /** * Processing settings for HTML files. */ export type HTML = { pretty_urls?: PrettyURLs; }; /** * Processing settings for image files. */ export type Images = { compress?: CompressImages; }; /** * Netlify Build Plugins extend the functionality of the build process */ export type BuildPlugins = { /** * Package name of the build plugin */ package: string; /** * Additional inputs for the build plugin */ inputs?: { [k: string]: unknown; }; }; /** * All deploys from the Production branch set in your site's Branches settings in the UI will inherit these settings. You can define environment variables here but we recommend using the Netlify UI for sensitive values to keep them out of your source repository. */ export type ProductionContext = { base?: BasePath; command?: BuildCommand; edge_functions?: EdgeFunctionsDirectory; environment?: EnvironmentVariables; plugins?: Plugins; processing?: PostProcessing; publish?: PublishPath; }; /** * All deploys generated from a pull/merge request will inherit these settings. */ export type DeployPreviewContext = { base?: BasePath; command?: BuildCommand; edge_functions?: EdgeFunctionsDirectory; environment?: EnvironmentVariables; plugins?: Plugins; processing?: PostProcessing; publish?: PublishPath; }; /** * All deploys that are not from a pull/merge request or from the Production branch will inherit these settings. */ export type BranchDeployContext = { base?: BasePath; command?: BuildCommand; edge_functions?: EdgeFunctionsDirectory; environment?: EnvironmentVariables; plugins?: Plugins; processing?: PostProcessing; publish?: PublishPath; }; /** * All deploys from this specific branch will inherit these settings. For contexts of branches with special characters, enclose the branch name with quotes. */ export type SpecificBranchContext = { base?: BasePath; command?: BuildCommand; edge_functions?: EdgeFunctionsDirectory; environment?: EnvironmentVariables; plugins?: Plugins; processing?: PostProcessing; publish?: PublishPath; }; /** * You can manage your redirects directly in your `netlify.toml`. For each redirect you want to declare, add an entry with the [[redirects]] heading. */ export type Redirects = { from: From; to?: To; status?: HTTPStatusCode; force?: Force; query?: QueryStringParameters; conditions?: Conditions; headers?: RequestHeaders; signed?: Signed; }; /** * Query string parameters REQUIRED to match the redirect. */ export type QueryStringParameters = { [k: string]: string; }; /** * Redirect based on conditions including browser language, geolocation, identity role, and/or cookie presence. */ export type Conditions = { Cookie?: CookiePresence; Country?: Country; Language?: Language; Role?: Role; [k: string]: unknown; }; /** * Additional request headers to send in proxy redirects. */ export type RequestHeaders = { [k: string]: string; }; /** * Define custom headers for specific paths. */ export type Headers = { for: For; values?: Values; }; /** * Define the actual headers. */ export type Values = { [k: string]: string; }; /** * Although there are default settings for Netlify Functions to help you get started, you can use this section for optional, custom configuration. */ export type Functions = { deno_import_map?: ImportMaps; external_node_modules?: ExternalNodeModules; included_files?: IncludedFiles; node_bundler?: NodeBundler; directory?: Directory; } & Record<string, { node_bundler?: NodeBundler; external_node_modules?: ExternalNodeModules; included_files?: IncludedFiles; }>; /** * Edge Functions connect the Netlify platform and workflow with an open runtime standard at the network edge. This enables you to build fast, personalized web experiences with an ecosystem of development tools. */ export type EdgeFunctions = { /** * The path pattern that needs to match for this edge function. */ path: string; /** * The name of the function. */ function: string; }; /** * Netlify Dev uses detectors to enable a local development environment for most tools and frameworks without any additional setup. You can use the `[dev]` section in `netlify.toml` for optional configuration. * * Note that `[dev]` doesn't run in the Bash shell, however, so you won't be able to use Bash-compatible syntax with the command. * * Netlify Dev also makes use of the functions directory setting to scaffold and serve your functions in a local development environment. */ export type NetlifyDev = { command?: DevCommand; port?: Port; targetPort?: TargetPort; functionsPort?: FunctionsPort; publish?: PublishPath1; jwtRolePath?: JWTRolePath; jwtSecret?: JWTSecret; autoLaunch?: PublishPath2; framework?: PublishPath3; https?: HTTPS; }; /** * Specify an SSL/TLS certificate and key file for the Netlify Dev local server. By default, Netlify Dev starts an HTTP server, but you can configure a certificate and key file if you require HTTPS. */ export type HTTPS = { certFile: CertificateFile; keyFile: PrivateKeyFile; };