Polymer Build (current version 3.1.4) is a Node.js library designed for building Polymer web component projects. It provides a highly customizable, stream-based pipeline for processing project source files and their dependencies, using Vinyl file objects. While the Polymer CLI utilizes `polymer-build` internally for its `build` command, this library offers greater flexibility for developers who require custom build steps, specific optimizers, or advanced stream manipulations not available through the CLI's pre-configured options. `polymer-build` enables direct interaction with build streams, allowing integration with other Node.js stream-based tools like Gulp. The Polymer ecosystem, including `polymer-build`, has largely been superseded by Lit for modern web component development, meaning this library is in a deprecated state with no new feature development expected.
npm install polymer-buildVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize a `PolymerProject` instance using either a `polymer.json` file or a default configuration. It then combines the project's source and dependency streams using `merge-stream` for a basic Gulp-based build process, outputting files to a `build/default` directory. It highlights the stream-centric nature of `polymer-build` and its integration with Gulp.
Consider migrating new projects or existing Polymer 3 projects to Lit for future development. `polymer-build` remains usable for existing Polymer 2.x/3.x applications but will not receive active feature development or significant updates.
Determine if the Polymer CLI's built-in `build` command meets your needs. If not, understand that `polymer-build` offers a lower-level API requiring more manual pipeline construction and integration with other Gulp/Node.js stream tools.
Ensure `polymer.json` is correctly structured and accessible, or that the `PolymerProject` constructor receives accurate `entrypoint`, `shell`, `fragments`, `sources`, and `extraDependencies` paths. Use glob patterns carefully for `sources` and `extraDependencies`.
Ensure you create an instance of `PolymerProject` using `const project = new PolymerProject(config);` before attempting to call its methods like `project.sources()`.
Verify the path to your `polymer.json` file. If you don't have one, pass the configuration object directly to the `PolymerProject` constructor instead of attempting to load from `polymer.json`.
Check the `shell` property in your `PolymerProject` configuration. Ensure it correctly points to the main application shell HTML file and that the file exists and is accessible relative to your project root or defined `sources`.