UNPKG

6.72 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
4 * This code may only be used under the BSD style license found at
5 * http://polymer.github.io/LICENSE.txt
6 * The complete set of authors may be found at
7 * http://polymer.github.io/AUTHORS.txt
8 * The complete set of contributors may be found at
9 * http://polymer.github.io/CONTRIBUTORS.txt
10 * Code distributed by Google as part of the polymer project is also
11 * subject to an additional IP rights grant found at
12 * http://polymer.github.io/PATENTS.txt
13 */
14import { BrowserCapability } from 'browser-capabilities';
15export declare type JsCompileTarget = 'es5' | 'es2015' | 'es2016' | 'es2017' | 'es2018';
16export interface ProjectBuildOptions {
17 /**
18 * The name of this build, used to determine the output directory name.
19 */
20 name?: string;
21 /**
22 * A build preset for this build. A build can inherit some base configuration
23 * from a named preset.
24 */
25 preset?: string;
26 /**
27 * Generate a service worker for your application to cache all files and
28 * assets on the client.
29 *
30 * Polymer CLI will generate a service worker for your build using the
31 * [sw-precache library](https://github.com/GoogleChrome/sw-precache). To
32 * customize your service worker, create a sw-precache-config.js file in your
33 * project directory that exports your configuration. See the [sw-precache
34 * README](https://github.com/GoogleChrome/sw-precache) for a list of all
35 * supported options.
36 *
37 * Note that the sw-precache library uses a cache-first strategy for maximum
38 * speed and makes some other assumptions about how your service worker should
39 * behave. Read the "Considerations" section of the sw-precache README to make
40 * sure that this is suitable for your application.
41 */
42 addServiceWorker?: boolean;
43 /**
44 * If `true`, generate an [HTTP/2 Push
45 * Manifest](https://github.com/GoogleChrome/http2-push-manifest) for your
46 * application.
47 */
48 addPushManifest?: boolean;
49 /**
50 * A config file that's passed to the [sw-precache
51 * library](https://github.com/GoogleChrome/sw-precache). See [its
52 * README](https://github.com/GoogleChrome/sw-precache) for details of the
53 * format of this file.
54 *
55 * Ignored if `addServiceWorker` is not `true`.
56 *
57 * Defaults to `"sw-precache-config.js`.
58 */
59 swPrecacheConfig?: string;
60 /**
61 * Insert prefetch link elements into your fragments so that all dependencies
62 * are prefetched immediately. Add dependency prefetching by inserting `<link
63 * rel="prefetch">` tags into entrypoint and `<link rel="import">` tags into
64 * fragments and shell for all dependencies.
65 *
66 * Note this option may trigger duplicate requests. See
67 * https://github.com/Polymer/polymer-build/issues/239 for details.
68 */
69 insertPrefetchLinks?: boolean;
70 /**
71 * By default, fragments are unbundled. This is optimal for HTTP/2-compatible
72 * servers and clients.
73 *
74 * If the --bundle flag is supplied, all fragments are bundled together to
75 * reduce the number of file requests. This is optimal for sending to clients
76 * or serving from servers that are not HTTP/2 compatible.
77 */
78 bundle?: boolean | {
79 /** URLs of files and/or folders that should not be inlined. */
80 excludes?: string[];
81 /** Inline external CSS file contents into <style> tags. */
82 inlineCss?: boolean;
83 /** Inline external Javascript file contents into <script> tags. */
84 inlineScripts?: boolean;
85 /** Rewrite element attributes inside of templates when inlining html. */
86 rewriteUrlsInTemplates?: boolean;
87 /** Create identity source maps for inline scripts. */
88 sourcemaps?: boolean;
89 /**
90 * Remove all comments except those tagged '@license', or starting with
91 * `<!--!` or `<!--#`, when true.
92 */
93 stripComments?: boolean;
94 /** Remove unreachable/unused code when bundling. */
95 treeshake?: boolean;
96 };
97 /** Options for processing HTML. */
98 html?: {
99 /** Minify HTMl by removing comments and whitespace. */
100 minify?: boolean | {
101 /** HTML files listed here will not be minified. */
102 exclude?: string[];
103 };
104 };
105 /** Options for processing CSS. */
106 css?: {
107 /** Minify inlined and external CSS. */
108 minify?: boolean | {
109 /** CSS files listed here will not be minified. */
110 exclude?: string[];
111 };
112 };
113 /** Options for processing JavaScript. */
114 js?: {
115 /** Minify inlined and external JavaScript. */
116 minify?: boolean | {
117 /** JavaScript files listed here will not be minified. */
118 exclude?: string[];
119 };
120 /** Use babel to compile all ES6 JS down to ES5 for older browsers. */
121 compile?: boolean | JsCompileTarget | {
122 target?: JsCompileTarget;
123 /** JavaScript files listed here will not be compiled. */
124 exclude?: string[];
125 };
126 /** Transform ES modules to AMD modules. */
127 transformModulesToAmd?: boolean;
128 };
129 /**
130 * Capabilities required for a browser to consume this build. Values include
131 * `es2015` and `push`. See canonical list at:
132 * https://github.com/Polymer/prpl-server-node/blob/master/src/capabilities.ts
133 *
134 * This field is purely a hint to servers reading this configuration, and
135 * does not affect the build process. A server supporting differential
136 * serving (e.g. prpl-server) can use this field to help decide which build
137 * to serve to a given user agent.
138 */
139 browserCapabilities?: BrowserCapability[];
140 /**
141 * Update the entrypoint's `<base>` tag, to support serving this build from a
142 * non-root path, such as when doing differential serving based on user
143 * agent. Requires that a `<base>` tag already exists. This works well in
144 * conjunction with the convention of using relative URLs for static
145 * resources and absolute URLs for application routes.
146 *
147 * If `true`, use the build `name`. If a `string`, use that value.
148 * Leading/trailing slashes are optional.
149 */
150 basePath?: boolean | string;
151}
152export declare const buildPresets: Map<string, ProjectBuildOptions>;
153export declare function isValidPreset(presetName: string): boolean;
154/**
155 * Apply a build preset (if a valid one exists on the config object) by
156 * deep merging the given config with the preset values.
157 */
158export declare function applyBuildPreset(config: ProjectBuildOptions): ProjectBuildOptions;