{"library":"polymer-build","title":"Polymer Build","description":"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.","language":"javascript","status":"deprecated","last_verified":"Tue Apr 21","install":{"commands":["npm install polymer-build"],"cli":{"name":"polymer","version":null}},"imports":["import { PolymerProject } from 'polymer-build';","import { HtmlSplitter } from 'polymer-build';","import type { ProjectOptions } from 'polymer-build';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { PolymerProject } from 'polymer-build';\nimport gulp from 'gulp';\nimport mergeStream from 'merge-stream';\nimport { resolve } from 'path';\nimport { readFileSync, existsSync } from 'fs';\n\n// This example demonstrates a basic Polymer build pipeline using Gulp.\n// Ensure 'gulp', 'merge-stream', and 'polymer-build' are installed.\n// For a real project, replace 'dummy-app' with your project structure.\n\nconst polymerJsonPath = resolve(process.cwd(), 'polymer.json');\nlet projectConfig = {};\n\nif (existsSync(polymerJsonPath)) {\n  projectConfig = JSON.parse(readFileSync(polymerJsonPath, 'utf-8'));\n} else {\n  // Fallback to a minimal example config if polymer.json is not found\n  console.warn('polymer.json not found. Using a default example configuration.');\n  projectConfig = {\n    entrypoint: 'index.html',\n    shell: 'src/my-app.html', // Adjust based on your app shell\n    fragments: ['src/my-view1.html', 'src/my-view2.html'], // Example fragments\n    sources: ['src/**/*', 'index.html', '!node_modules/**/*'], // Include all sources, exclude node_modules\n    extraDependencies: ['node_modules/@webcomponents/webcomponentsjs/**/*'], // Example polyfills\n  };\n}\n\n// Create a PolymerProject instance with the determined configuration\nconst project = new PolymerProject(projectConfig);\n\ngulp.task('build', () => {\n  console.log('Starting Polymer build...');\n  // Merge project sources and dependencies into a single stream\n  const mergedStreams = mergeStream(project.sources(), project.dependencies());\n\n  return mergedStreams\n    // You can add custom build steps here, e.g., linting, optimization, minification\n    // .pipe(myCustomOptimizer())\n    .pipe(gulp.dest('build/default')) // Output to a 'build/default' directory\n    .on('end', () => console.log('Polymer build completed. Output in build/default/.'));\n});\n\n// To run this Gulp task:\n// 1. Install dependencies: `npm install --save-dev gulp merge-stream polymer-build`\n// 2. Create a `gulpfile.ts` (or `.js`) in your project root with this code.\n// 3. Create a basic `index.html` and `src/my-app.html` (or other configured entrypoints).\n// 4. Run `npx gulp build` from your terminal.","lang":"typescript","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}