@ecl/builder

中文文档
5.4.1发布于 2026/11/10EUPL-1.2ES Module近 30 天下载 6119

Europa Component Library builder

原始使用文档

ECL Builder

Configuration

By default, ecl-builder will read the ecl-builder.config.js file at the root of your project. You can use the -c or --config parameter if you want to give your configuration file another name.

Typically, this is what it should look like:

const path = require('path');
const isProd = process.env.NODE_ENV === 'production';

module.exports = {
  // Compile entry.js
  scripts: [
    {
      entry: path.resolve(__dirname, 'src/entry.js'),
      dest: path.resolve(__dirname, 'dist/output.js'),
      options: {
        sourceMap: isProd ? false : 'inline',
        moduleName: 'myModule',
      },
    },
  ],
  // Compile entry.scss
  styles: [
    {
      entry: path.resolve(__dirname, 'src/entry.scss'),
      dest: path.resolve(__dirname, 'dist/output.css'),
      options: {
        sourceMap: isProd ? 'file' : true,
        minify: true,
      },
    },
  ],
  // Copy files from src to dest
  copy: [
    {
      from: path.resolve(__dirname, 'src/fonts'),
      to: path.resolve(__dirname, 'dist/fonts'),
    },
    {
      from: path.resolve(__dirname, 'src/images'),
      to: path.resolve(__dirname, 'dist/images'),
    },
  ],
};

Watch mode

ECL builder provides a thin wrapper on top of browsersync for facilitating development workflows with the assets mentioned above.

Example configuration:

{
    init: {
      proxy: `${app.host}:${app.port}`,
    },
    handlers: [
      {
        pattern: `./(dev|ec-core)/src/*.scss`,
        events: [
          {
            on: 'change',
            name: 'dev/ec-core presets scss changes',
            command: 'npm run build:styles',
            message: 'New styles ready',
            reload: '*.css',
          },
        ],
      },
    ]
}

The object passed to init is merged with the same method from browsersync. ECL uses the proxy option for it's storybook instances, but this could be any other application such as a Drupal website.

handlers define a list of event handlers spawning .watch() tasks.

The value for on property matches the chokidar's events.

reload is the same as browsersync's reload(). It's optional and could be most useful in handlers related to changes in styles (scss/css) which can be injected on the page without full page reload with reload("*.css"). In all other cases, passing the function with empty parameters will cause a full page reload.

版本与发布记录

@ecl/builder 共发布 168 个版本,首次发布于 2018/03/13;过去 12 个月发布了 25 个版本。

版本发布日期距今
5.4.1latest2026/11/103 天前
5.4.02026/10/2222 天前
5.3.22026/10/081 个月前
5.3.12026/09/211 个月前
5.3.02026/09/151 个月前
5.2.22026/09/082 个月前

关于 @ecl/builder 的常见问题

@ecl/builder 是什么?

Europa Component Library builder

如何安装 @ecl/builder?

在项目目录运行 npm install @ecl/builder,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 ecl-builder,可以用 npx ecl-builder 直接运行。

@ecl/builder 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/ecl__builder 是否存在。

@ecl/builder 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@ecl/builder 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.12.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@ecl/builder 可以商用吗?

@ecl/builder 使用 EUPL-1.2 许可。声明的许可为 EUPL-1.2,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@ecl/builder 的下载量有多少?

根据 npm 官方下载统计,@ecl/builder 在 2026/10/13 – 2026/11/11 这 30 天内被下载 6,119 次,日均约 204 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@ecl/builder 还在维护吗?

最新版本 5.4.1 发布于 2026/11/10(3 天前);至今共发布 168 个版本,其中过去 12 个月发布了 25 个;首次发布于 2018/03/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。