How netcentric/fe-build works
Project Type and Purpose
• This is an open-source, CLI-driven “all-in-one” frontend build toolkit (npm package) specifically tailored to Adobe Experience Manager (AEM) projects.
• Its job is to read a project’s source files (JS and SCSS), apply linting, transpilation, bundling, and CSS compilation, then output AEM-compatible ClientLib folder structures.
File‐Structure Analysis
• Top‐level “cli/index.js”: the entry point exposing the nc-fe-build command.
• “config/”: modular webpack, babel, postcss, stylelint, performance and general build configurations.
• “tasks/”: discrete task modules (run.js, webpack.js, styles.js, clientlibs.js) each orchestrating a build step, plus unit tests.
• “utils/”: helper functions for merging configs, resolving entry points, loading plugins, file I/O, logging, and lint-error formatting.
README Insights
• Core features: ESLint → Babel → Webpack for JS, Stylelint → Sass → PostCSS/Autoprefixer for CSS, automatic ClientLib structure generation.
• Configuration is extensible via .febuild and the various config/*.js modules.
• Emphasis on automation, plugin-based config, and integration with AEM’s clientlibs.
a. Main Components
• CLI Interface (cli/index.js)
• Task Orchestrator (tasks/run.js)
• Task Modules:
• JS Build Task (tasks/webpack.js)
• CSS Build Task (tasks/styles.js)
• ClientLib Generation Task (tasks/clientlibs.js)
• Config Layer (config/*.js)
• Utility Layer (utils/*.js)
• External Tools/Engines: Node.js, ESLint, Babel, Webpack, Stylelint, Sass, PostCSS
• File System: Source Directory (src/*.source.js|scss), Output (AEM ClientLib folder)
b. Relationships & Data Flows
• User runs nc-fe-build → CLI Interface parses args → passes control to Task Orchestrator.
• Task Orchestrator loads and merges configurations via Config Layer & Utils.
• For JS Task: reads entry points → ESLint → Babel transforms → Webpack bundles → writes JS assets.
• For CSS Task: reads SCSS → Stylelint → Sass compiler → PostCSS (Autoprefixer) → writes CSS assets.
• ClientLib Task: scans generated assets → builds css.txt and js.txt → emits AEM ClientLib folder structure.
• Each task reports status through Utils/log and exits.
c. Architectural Patterns & Principles
• Modular Pipeline: each build step encapsulated in its own “task” module.
• Plugin/Config Factory: Config Layer exposes composable functions, merged via Utils.
• Single Responsibility & Separation of Concerns: CLI, Orchestrator, Tasks, Configs, and Utils are distinct layers.
• Test-driven Utility modules: each util function is unit-tested.
d. Key Technologies & Frameworks
• Node.js & npm (CLI runtime)
• ESLint, Stylelint (linting)
• Babel (JS transpilation)
• Webpack (+ Bundle Analyzer) (JS bundling)
• Sass, PostCSS (+ Autoprefixer) (CSS processing)
• AEM ClientLib spec (output consumer)