UNPKG

3.57 kBTypeScriptView Raw
1import { ValidatorResult } from 'jsonschema';
2import type HttpProxy from 'http-proxy';
3import { Plugin as RollupPlugin } from 'rollup';
4declare type ScriptType = 'mount' | 'run' | 'build' | 'bundle';
5export declare type EnvVarReplacements = Record<string, string | number | true>;
6/** Snowpack export map */
7export declare type SnowpackBuildMap = {
8 [outputLoc: string]: SnowpackSourceFile;
9};
10/** Standard file interface */
11export interface SnowpackSourceFile {
12 /** base extension (e.g. `.js`) */
13 baseExt: string;
14 /** file contents */
15 code: string;
16 /** expanded extension (e.g. `.proxy.js` or `.module.css`) */
17 expandedExt: string;
18 /** if no location on disk, assume this exists in memory */
19 locOnDisk?: string;
20}
21export declare type SnowpackPluginBuildArgs = {
22 contents: string;
23 filePath: string;
24 isDev: boolean;
25};
26export declare type SnowpackPluginTransformArgs = {
27 contents: string;
28 urlPath: string;
29 isDev: boolean;
30};
31export declare type SnowpackPluginBuildResult = {
32 result: string;
33 resources?: {
34 css?: string;
35 };
36};
37export declare type SnowpackPluginTransformResult = {
38 result: string;
39 resources?: {
40 css?: string;
41 };
42};
43export declare type SnowpackPlugin = {
44 defaultBuildScript?: string;
45 knownEntrypoints?: string[];
46 build?: (args: SnowpackPluginBuildArgs) => null | SnowpackPluginBuildResult | Promise<null | SnowpackPluginBuildResult>;
47 transform?: (args: SnowpackPluginTransformArgs) => null | SnowpackPluginTransformResult | Promise<null | SnowpackPluginTransformResult>;
48 bundle?(args: {
49 srcDirectory: string;
50 destDirectory: string;
51 jsFilePaths: Set<string>;
52 log: (msg: any) => void;
53 }): Promise<void>;
54};
55export declare type BuildScript = {
56 id: string;
57 match: string[];
58 type: ScriptType;
59 cmd: string;
60 watch?: string;
61 plugin?: SnowpackPlugin;
62 args?: any;
63};
64export declare type ProxyOptions = HttpProxy.ServerOptions & {
65 on: Record<string, Function>;
66};
67export declare type Proxy = [string, ProxyOptions];
68export interface SnowpackConfig {
69 install: string[];
70 extends?: string;
71 exclude: string[];
72 knownEntrypoints: string[];
73 webDependencies?: {
74 [packageName: string]: string;
75 };
76 scripts: BuildScript[];
77 plugins: SnowpackPlugin[];
78 devOptions: {
79 secure: boolean;
80 port: number;
81 out: string;
82 fallback: string;
83 open: string;
84 bundle: boolean | undefined;
85 hmr: boolean;
86 };
87 installOptions: {
88 dest: string;
89 env: EnvVarReplacements;
90 treeshake?: boolean;
91 installTypes: boolean;
92 sourceMap?: boolean | 'inline';
93 externalPackage: string[];
94 alias: {
95 [key: string]: string;
96 };
97 namedExports: string[];
98 rollup: {
99 plugins: RollupPlugin[];
100 dedupe?: string[];
101 };
102 };
103 buildOptions: {
104 baseUrl: string;
105 metaDir: string;
106 };
107 proxy: Proxy[];
108}
109export interface CLIFlags extends Omit<Partial<SnowpackConfig['installOptions']>, 'env'> {
110 help?: boolean;
111 version?: boolean;
112 reload?: boolean;
113 config?: string;
114 env?: string[];
115 open?: string[];
116 secure?: boolean;
117}
118export declare function createConfiguration(config: Partial<SnowpackConfig>): [ValidatorResult['errors'], undefined] | [null, SnowpackConfig];
119export declare function loadAndValidateConfig(flags: CLIFlags, pkgManifest: any): SnowpackConfig;
120export {};