Skip to content

Commit

Permalink
Fix #827. Merge commandline options with named build configuration op…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
alber70g committed Nov 17, 2017
1 parent 9eefa86 commit 4998f59
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,7 @@
an interactive prompt and the `--edits` flag. See `polymer lint --help` for
more info.
- `build` Added a CLI argument for setting the `basePath` option: `--base-path`.
- `build` When using flag `--name <buildName>`, it will now take the matching named build from `polymer.json` and merge it with the command-line options. This fixes #827.
<!-- Add new, unreleased items here. -->

## v1.5.7 [10-11-2017]
Expand Down
14 changes: 12 additions & 2 deletions src/build/build.ts
Expand Up @@ -38,8 +38,18 @@ export async function build(
options: ProjectBuildOptions,
polymerProject: PolymerProject): Promise<void> {
const buildName = options.name || 'default';
const optimizeOptions:
OptimizeOptions = {css: options.css, js: options.js, html: options.html};

// If a config for the current buildName is present
// Merge the projects optimizeOptions with the options
// Commandline options will override the projects options
const projectOptions = polymerProject.config.builds.find(buildConfig => buildConfig.name === buildName);
let optimizeOptions: OptimizeOptions;
if (projectOptions) {
const projectOptimizeOptions = {css: projectOptions.css, js: projectOptions.js, html: projectOptions.html};
optimizeOptions = Object.assign({}, projectOptimizeOptions, options);
} else {
optimizeOptions = {css: options.css, js: options.js, html: options.html};
}

// If no name is provided, write directly to the build/ directory.
// If a build name is provided, write to that subdirectory.
Expand Down

0 comments on commit 4998f59

Please sign in to comment.