UNPKG

3.88 kBJavaScriptView Raw
1"use strict";
2/**
3 * @license
4 * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
5 * This code may only be used under the BSD style license found at
6 * http://polymer.github.io/LICENSE.txt
7 * The complete set of authors may be found at
8 * http://polymer.github.io/AUTHORS.txt
9 * The complete set of contributors may be found at
10 * http://polymer.github.io/CONTRIBUTORS.txt
11 * Code distributed by Google as part of the polymer project is also
12 * subject to an additional IP rights grant found at
13 * http://polymer.github.io/PATENTS.txt
14 */
15Object.defineProperty(exports, "__esModule", { value: true });
16exports.buildPresets = new Map([
17 [
18 'es5-bundled',
19 {
20 name: 'es5-bundled',
21 js: {
22 minify: true,
23 compile: 'es5',
24 transformModulesToAmd: true,
25 },
26 css: { minify: true },
27 html: { minify: true },
28 bundle: true,
29 addServiceWorker: true,
30 addPushManifest: false,
31 }
32 ],
33 [
34 'es6-bundled',
35 {
36 name: 'es6-bundled',
37 browserCapabilities: ['es2015'],
38 js: {
39 minify: true,
40 compile: 'es2015',
41 transformModulesToAmd: true,
42 },
43 css: { minify: true },
44 html: { minify: true },
45 bundle: true,
46 addServiceWorker: true,
47 addPushManifest: false,
48 }
49 ],
50 [
51 'es6-unbundled',
52 {
53 name: 'es6-unbundled',
54 browserCapabilities: ['es2015', 'push'],
55 js: {
56 minify: true,
57 compile: 'es2015',
58 transformModulesToAmd: true,
59 },
60 css: { minify: true },
61 html: { minify: true },
62 bundle: false,
63 addServiceWorker: true,
64 addPushManifest: true,
65 }
66 ],
67 [
68 'uncompiled-bundled',
69 {
70 name: 'uncompiled-bundled',
71 browserCapabilities: ['es2018', 'modules'],
72 js: { minify: true },
73 css: { minify: true },
74 html: { minify: true },
75 bundle: true,
76 addServiceWorker: true,
77 addPushManifest: false,
78 }
79 ],
80 [
81 'uncompiled-unbundled',
82 {
83 name: 'uncompiled-unbundled',
84 browserCapabilities: ['es2018', 'modules', 'push'],
85 js: { minify: true },
86 css: { minify: true },
87 html: { minify: true },
88 bundle: false,
89 addServiceWorker: true,
90 addPushManifest: true,
91 }
92 ],
93]);
94function isValidPreset(presetName) {
95 return exports.buildPresets.has(presetName);
96}
97exports.isValidPreset = isValidPreset;
98/**
99 * Apply a build preset (if a valid one exists on the config object) by
100 * deep merging the given config with the preset values.
101 */
102function applyBuildPreset(config) {
103 const presetName = config.preset;
104 if (!presetName || !isValidPreset(presetName)) {
105 return config;
106 }
107 const presetConfig = exports.buildPresets.get(presetName) || {};
108 const mergedConfig = Object.assign({}, presetConfig, config);
109 // Object.assign is shallow, so we need to make sure we properly merge these
110 // deep options as well.
111 // NOTE(fks) 05-05-2017: While a little annoying, we use multiple
112 // Object.assign() calls here so that we do not filter-out additional
113 // user-defined build options at the config level.
114 mergedConfig.js = Object.assign({}, presetConfig.js, config.js);
115 mergedConfig.css = Object.assign({}, presetConfig.css, config.css);
116 mergedConfig.html = Object.assign({}, presetConfig.html, config.html);
117 return mergedConfig;
118}
119exports.applyBuildPreset = applyBuildPreset;
120//# sourceMappingURL=builds.js.map
\No newline at end of file