index.d.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { Ora } from 'ora';
  2. import { Plugin, InputOption, InputOptions, OutputOptions, RollupOutput } from 'rollup';
  3. import { InternalResolver } from '../resolver';
  4. import { BuildConfig } from '../config';
  5. interface Build extends InputOptions {
  6. input: InputOption;
  7. output: OutputOptions;
  8. /** Runs before global post-build hooks. */
  9. onResult?: PostBuildHook;
  10. }
  11. export interface BuildResult {
  12. build: Build;
  13. html: string;
  14. assets: RollupOutput['output'];
  15. }
  16. /** For adding Rollup builds and mutating the Vite config. */
  17. export declare type BuildPlugin = (config: BuildConfig, builds: Build[]) => PostBuildHook | void;
  18. /** Returned by `configureBuild` hook to mutate a build's output. */
  19. export declare type PostBuildHook = (result: BuildResult) => Promise<void> | void;
  20. export declare function onRollupWarning(spinner: Ora | undefined, options: BuildConfig['optimizeDeps']): InputOptions['onwarn'];
  21. /**
  22. * Creates non-application specific plugins that are shared between the main
  23. * app and the dependencies. This is used by the `optimize` command to
  24. * pre-bundle dependencies.
  25. */
  26. export declare function createBaseRollupPlugins(root: string, resolver: InternalResolver, options: Partial<BuildConfig>): Promise<Plugin[]>;
  27. /**
  28. * Bundles the app for production.
  29. * Returns a Promise containing the build result.
  30. */
  31. export declare function build(options: Partial<BuildConfig>): Promise<BuildResult[]>;
  32. /**
  33. * Bundles the app in SSR mode.
  34. * - All Vue dependencies are automatically externalized
  35. * - Imports to dependencies are compiled into require() calls
  36. * - Templates are compiled with SSR specific optimizations.
  37. */
  38. export declare function ssrBuild(options: Partial<BuildConfig>): Promise<BuildResult[]>;
  39. export {};