UNPKG

3.42 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright (c) 2016 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 */
14/// <reference types="node" />
15import { JsCompileTarget, ModuleResolutionStrategy } from 'polymer-project-config';
16import { Transform } from 'stream';
17import * as vinyl from 'vinyl';
18import File = require('vinyl');
19export declare type FileCB = (error?: Error, file?: File) => void;
20export declare type CSSOptimizeOptions = {
21 stripWhitespace?: boolean;
22};
23export interface OptimizeOptions {
24 html?: {
25 minify?: boolean | {
26 exclude?: string[];
27 };
28 };
29 css?: {
30 minify?: boolean | {
31 exclude?: string[];
32 };
33 };
34 js?: JsOptimizeOptions;
35 entrypointPath?: string;
36 rootDir?: string;
37}
38export declare type JsCompileOptions = boolean | JsCompileTarget | {
39 target?: JsCompileTarget;
40 exclude?: string[];
41};
42export interface JsOptimizeOptions {
43 minify?: boolean | {
44 exclude?: string[];
45 };
46 compile?: JsCompileOptions;
47 moduleResolution?: ModuleResolutionStrategy;
48 transformModulesToAmd?: boolean;
49}
50/**
51 * GenericOptimizeTransform is a generic optimization stream. It can be extended
52 * to create a new kind of specific file-type optimizer, or it can be used
53 * directly to create an ad-hoc optimization stream for different libraries.
54 * If the transform library throws an exception when run, the file will pass
55 * through unaffected.
56 */
57export declare class GenericOptimizeTransform extends Transform {
58 optimizer: (content: string, file: File) => string;
59 optimizerName: string;
60 constructor(optimizerName: string, optimizer: (content: string, file: File) => string);
61 _transform(file: File, _encoding: string, callback: FileCB): void;
62}
63/**
64 * Transform JavaScript.
65 */
66export declare class JsTransform extends GenericOptimizeTransform {
67 constructor(options: OptimizeOptions);
68}
69/**
70 * Transform HTML.
71 */
72export declare class HtmlTransform extends GenericOptimizeTransform {
73 constructor(options: OptimizeOptions);
74}
75/**
76 * CSSMinifyTransform minifies CSS that pass through it (via css-slam).
77 */
78export declare class CSSMinifyTransform extends GenericOptimizeTransform {
79 private options;
80 constructor(options: CSSOptimizeOptions);
81 _transform(file: File, encoding: string, callback: FileCB): void;
82}
83/**
84 * InlineCSSOptimizeTransform minifies inlined CSS (found in HTML files) that
85 * passes through it (via css-slam).
86 */
87export declare class InlineCSSOptimizeTransform extends GenericOptimizeTransform {
88 private options;
89 constructor(options: CSSOptimizeOptions);
90 _transform(file: File, encoding: string, callback: FileCB): void;
91}
92/**
93 * Returns an array of optimization streams to use in your build, based on the
94 * OptimizeOptions given.
95 */
96export declare function getOptimizeStreams(options?: OptimizeOptions): NodeJS.ReadWriteStream[];
97export declare function matchesExt(extension: string): (fs: vinyl) => boolean;