@creativestyle/magesuite-frontend-builder

中文文档
5.1.0发布于 2026/10/21MITES Module近 30 天下载 2280

A modern build system for Magento 2 / MageSuite themes built on Webpack 5, TypeScript, and Gulp 5. Provides webpack bundling, SCSS compilation, asset copying, image optimisation, linting, BrowserSync dev proxy, and Magento cache management — a

原始使用文档
文档目录35 节
  1. Features
  2. Quick start
  3. Directory structure
  4. Theme inheritance system
  5. Parent theme setup
  6. Theme integration
  7. Child theme package.json
  8. Child theme tsconfig.json
  9. Child theme src/declarations.d.ts
  10. Development workflow
  11. Starting development
  12. Production build
  13. Linting
  14. Interactive menu
  15. Adding to a theme
  16. Menu groups
  17. TypeScript compilation pipeline
  18. resolutions — caniuse-lite
  19. Package reference
  20. Build orchestration
  21. Webpack and JS bundling
  22. CSS processing
  23. Asset handling
  24. Linting and formatting
  25. Interactive menu
  26. Git hooks
  27. What changed in v5.0 vs v4.x
  28. Adopted
  29. Intentionally suppressed — and why
  30. Troubleshooting
  31. CSS not injecting via BrowserSync
  32. "Module not found" errors
  33. Stale webpack cache after branch switch
  34. [DEP0060] util._extend deprecation during yarn serve
  35. Further reading

@creativestyle/magesuite-frontend-builder

A modern build system for Magento 2 / MageSuite themes built on Webpack 5, TypeScript, and Gulp 5. Provides webpack bundling, SCSS compilation, asset copying, image optimisation, linting, BrowserSync dev proxy, and Magento cache management — all wired together in a single package consumed by child themes.


Features

  • Webpack 5 with TypeScript compilation and persistent filesystem cache
  • Hot CSS injection via BrowserSync — no page reloads for style changes
  • Multi-level theme inheritance — file resolution walks the full theme.xml parent chain
  • Modern tooling — ESLint flat config, Stylelint v17, Prettier, Husky v9, lint-staged
  • Interactive command menu — yarn menu for arrow-key navigation of all available tasks
  • Production optimisation — CSS minification, image compression, WOFF2-only fonts

Quick start

yarn install

yarn menu           # interactive command menu — recommended starting point
yarn build          # production build
yarn build:verbose  # production build with full asset size report
yarn serve          # development watch mode with BrowserSync
yarn lint           # ESLint + Stylelint
yarn lint:js        # ESLint only
yarn lint:css       # Stylelint only

Individual gulp tasks can also be run directly. Use yarn gulp <task> — not bare gulp <task> (no global install) and not yarn <task> (these tasks are not listed in package.json scripts):

yarn gulp cleanWebpackCache   # wipe webpack filesystem cache
yarn gulp eslint --fix        # lint and auto-fix JS/TS
yarn gulp stylelint --fix     # lint and auto-fix SCSS

Directory structure

magesuite-frontend-builder/
├── registry.js                 # Entry point — registers all tasks and composes build/serve/watch
├── menu.js                     # Interactive CLI menu binary (magesuite-menu)
├── eslint.config.js            # ESLint flat config (JS + TS, Prettier integration)
├── package.json
│
├── config/                     # Theme-level config files re-exported by child themes
│   ├── lint-staged.js          # lint-staged config — runs ESLint + Stylelint on staged files
│   ├── prettier.js             # Prettier config
│   └── stylelint.js            # Stylelint config
│
└── gulp/
    ├── environment.js          # CLI flag parser — development / production / ci / watch / verbose
    ├── paths.js                # Resolved src/dist/pubStatic paths from composer.json
    ├── collectEntries.js       # Resolves webpack entry points across theme inheritance chain
    ├── collectParents.js       # Walks theme.xml <parent> chain → ordered list of parent paths
    ├── parentAliases.js        # Builds webpack alias map (e.g. Creativeshop → parent src/)
    ├── skipUnchangedPlugin.js  # Webpack plugin — skips emitting assets identical to dist
    ├── imageminStream.js       # Gulp stream that runs images through imagemin plugins
    ├── imageminSharpJpeg.js    # Imagemin plugin — JPEG compression with sharp's mozjpeg encoder
    ├── imageminSharpPng.js     # Imagemin plugin — PNG palette compression with sharp's libimagequant
    ├── srcExists.js            # Guards gulp.src() calls — prevents ENOENT when optional dirs are absent
    │
    ├── config/                 # Per-task configuration
    │   ├── browserSync.js      # BrowserSync proxy settings and all rewrite middleware
    │   ├── buildSprites.js     # SVG sprite generation settings
    │   ├── buildWebpack.js     # Full webpack configuration (entries, loaders, plugins, cache)
    │   ├── clean.js            # Paths deleted by the clean task
    │   ├── cleanCache.js       # Magento cache types + connection config (ssh/local/docker)
    │   ├── collectViewXml.js   # Source paths for view.xml collection
    │   ├── copyDocs.js         # Glob patterns for documentation assets
    │   ├── copyHtml.js         # Glob patterns for HTML templates
    │   ├── copyImages.js       # Glob patterns + imagemin plugin options
    │   ├── copyScripts.js      # Glob patterns for plain JS vendor scripts
    │   └── copyUnchanged.js    # Glob patterns for all other static assets
    │
    └── tasks/                  # Individual gulp task implementations
        ├── browserSync.js
        ├── buildWebpack.js
        ├── clean.js
        ├── cleanCache.js
        ├── cleanWebpackCache.js
        ├── collectViewXml.js
        ├── copyDocs.js
        ├── copyHtml.js
        ├── copyImages.js
        ├── copyScripts.js
        ├── copyUnchanged.js
        ├── eslint.js
        ├── generateCerts.js
        └── stylelint.js

Theme inheritance system

The builder supports multi-level theme inheritance. File resolution walks the full theme.xml parent chain at build time:

theme-creativeshop  (base)
└── theme-child
    └── theme-grandchild

Resolution order for any given file:

  1. Current theme src/
  2. Parent theme src/
  3. Base theme src/ (theme-creativeshop)
  4. node_modules/

Webpack aliases and module resolution paths are populated automatically from this chain — no manual path configuration needed in child themes.

Parent theme setup

Each theme declares its parent in src/theme.xml:

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
    <title>Child Theme</title>
    <parent>Creativestyle/theme-creativeshop</parent>
</theme>

The builder reads this file to build the alias map and resolve entry points across all levels of the chain.


Theme integration

Themes consume the builder via gulpfile.mjs:

import gulp from 'gulp';
import registry from '@creativestyle/magesuite-frontend-builder';
gulp.registry(registry);

To override webpack config, add a webpack.config.js to your theme root — it will be deep-merged with the base config via webpack-merge.

Child theme package.json

{
    "scripts": {
        "menu":         "magesuite-menu",
        "build":        "gulp build --env production",
        "build:verbose":"gulp build --env production --verbose",
        "serve":        "gulp serve",
        "start":        "gulp serve",
        "lint:js":      "gulp eslint",
        "lint:css":     "gulp stylelint",
        "lint":         "gulp eslint && gulp stylelint",
        "prepare":      "husky"
    },
    "resolutions": {
        "caniuse-lite": "^1.0.30001781"
    }
}

Child theme tsconfig.json

{
    "compilerOptions": {
        "target": "ES2022",
        "module": "commonjs",
        "moduleResolution": "node",
        "noEmit": true,
        "skipLibCheck": true,
        "paths": {
            "*": ["./src/*", "./node_modules/*", "../theme-creativeshop/src/*"]
        }
    }
}

Child theme src/declarations.d.ts

declare module '*.scss';
declare module 'mage/*';

TypeScript has no built-in understanding of SCSS imports or Magento's RequireJS modules, so without this file tsc (and the ESLint TypeScript parser) would error on:

  • import '*.scss' — theme TS files often import SCSS; TypeScript treats unknown extensions as missing modules.
  • import ... from 'mage/translate' etc. — Magento core ships no .d.ts files, so all mage/* imports are unresolved types.

The file suppresses both classes of errors globally without touching any theme source file.


Development workflow

Starting development

# Install dependencies
yarn install

# Start the development server
yarn serve

BrowserSync starts a reverse proxy in front of Magento. CSS changes are injected without a page reload; JS changes trigger a reload. SSL is handled automatically via mkcert — see LOCAL_SSL_CERT.md.

Production build

yarn build          # concise summary output
yarn build:verbose  # full asset list with sizes and all warnings

Linting

yarn lint           # ESLint + Stylelint
yarn lint:js        # ESLint + tsc --noEmit
yarn lint:css       # Stylelint

# Auto-fix formatting and fixable violations
yarn gulp eslint --fix
yarn gulp stylelint --fix

The pre-commit hook (Husky + lint-staged) runs ESLint and Stylelint automatically on staged files before every commit.


Interactive menu

yarn menu opens an arrow-key navigable launcher with per-item descriptions. No need to remember command names.

Adding to a theme

"scripts": {
    "menu": "magesuite-menu"
}

The binary is wired up automatically via the bin field in the builder's package.json.

Menu groups

GroupCommands
Buildbuild, build:verbose, serve
Lintlint, lint:js, lint:css, lint --fix, lint:js --fix, lint:css --fix
UtilitiescleanWebpackCache, pre-commit

TypeScript compilation pipeline

TypeScript is compiled by ts-loader inside Webpack with transpileOnly: true — strips types and emits JavaScript but skips type checking. This keeps build times fast.

Type checking is handled separately by tsc --noEmit, which runs alongside ESLint during yarn lint:js:

yarn build    → Webpack + ts-loader (transpileOnly: true) → fast, no type errors surfaced
yarn lint:js  → tsc --noEmit + ESLint                    → type errors and lint violations reported

The pre-commit hook runs ESLint on staged files only — not tsc. Type errors do not block commits; they surface via yarn lint:js or CI.


resolutions — caniuse-lite

Add a resolutions field to the child theme's package.json:

"resolutions": {
    "caniuse-lite": "^1.0.30001781"
}

caniuse-api (a transitive dependency of autoprefixer) declares caniuse-lite@^1.0.0 — a loose range that resolves to a stale version, triggering "browsers data is N months old" warnings on every build. The resolutions field collapses all nested caniuse-lite entries to a single up-to-date version in yarn.lock.

Run yarn install --force after adding the field to apply the resolution.


Package reference

Build orchestration

PackagePurpose
gulp v5Task runner and pipeline orchestrator
undertaker-registryAllows themes to consume all tasks via gulp.registry()
yargsCLI argument parsing (--env, --verbose, --fix, --watch)
fancy-logTimestamped console output used across all tasks
plugin-errorStructured gulp error objects for task failure reporting
chalkTerminal colour output — used in build banner and warning messages

Webpack and JS bundling

PackagePurpose
webpack v5Module bundler — compiles TypeScript entry points, bundles SCSS
webpack-merge v6Deep-merges child theme webpack.config.js overrides into base config
ts-loaderWebpack loader for TypeScript transpilation (transpileOnly mode)
typescriptTypeScript compiler (used by ts-loader)
@types/jqueryType definitions for jQuery (available globally in Magento)
@types/requirejsType definitions for RequireJS (used in Magento module overrides)
glob v13Resolves entry point file patterns across the theme inheritance chain

CSS processing

PackagePurpose
sassDart Sass compiler — compiles SCSS to CSS
sass-loader v17Webpack loader that invokes Dart Sass
css-loader v7Resolves CSS @import and url() inside webpack
mini-css-extract-pluginExtracts compiled CSS into separate .css files per entry point
css-minimizer-webpack-pluginMinifies extracted CSS in production builds
postcss-loader v8Runs PostCSS plugins on compiled CSS
autoprefixerPostCSS plugin — adds vendor prefixes based on Browserslist targets
postcss-flexbugs-fixesPostCSS plugin — patches known flexbox bugs across browsers

Asset handling

PackagePurpose
gulp-changedSkips copying files that haven't changed since the last build
imagemin v9Image optimisation core, run through the builder's own gulp/imageminStream.js (production only)
sharp v0.35Lossy JPEG compression via the mozjpeg encoder and lossy PNG compression via the libimagequant palette quantiser, both bundled in sharp. Ships native builds for every platform, so nothing is downloaded during yarn install and no Rosetta is needed on Apple Silicon
imagemin-svgo v10SVG optimisation via svgo v2
del v8Deletes files and directories

Linting and formatting

PackagePurpose
eslint v10JavaScript and TypeScript linter — flat config format (eslint.config.js)
@eslint/jsESLint's built-in recommended JS rule set
typescript-eslintTypeScript-aware lint rules and TS parser
prettierOpinionated code formatter — enforced via ESLint and Stylelint
eslint-config-prettierDisables ESLint formatting rules that conflict with Prettier
eslint-plugin-prettierRuns Prettier as an ESLint rule
stylelint v17SCSS linter
stylelint-scssSCSS-specific lint rules
stylelint-config-recommended-scssRecommended rules for SCSS
stylelint-prettierRuns Prettier as a Stylelint rule
postcss-scssPostCSS syntax for parsing SCSS (required by Stylelint)

Interactive menu

PackagePurpose
@clack/promptsTerminal UI components — intro, outro, select, log
@clack/coreUnstyled prompt primitives — SelectPrompt used for custom Ctrl+C cancel behaviour

Git hooks

PackagePurpose
husky v9Manages git hooks — runs lint-staged on pre-commit
lint-staged v17Runs linters only on staged files

What changed in v5.0 vs v4.x

Adopted

AreaChange
Webpack v5Replaced webpack v4. Built-in filesystem cache replaces cache-loader — faster incremental builds
CSS minificationcss-minimizer-webpack-plugin replaces deprecated optimize-css-assets-webpack-plugin
Native ESMBuilder converted from CJS to native ES modules ("type": "module"). All require() / module.exports replaced with import / export default
ESM packagesdel, glob, gulp, gulp-imagemin, imagemin-* are ESM-only; now imported statically
MagesuiteRegistry classModernised from ES5 util.inherits + prototype pattern to ES6 class extends DefaultRegistry
ESLint v10 flat configMigrated from .eslintrc.js legacy config to eslint.config.js flat config format
Dart Sass 1.xsass-loader v16 auto-detects Dart Sass; implementation: sass option removed
BrowserSync v3Full HTTPS proxy with URL rewriting, cookie domain fixes, CSP stripping, and POST body rewriting for Magento link masking compatibility
Verbose build output--verbose flag shows full asset sizes and warnings; default build shows only a concise summary line
Interactive menumagesuite-menu binary — arrow-key navigable command launcher

Intentionally suppressed — and why

SuppressionReasonShould devs adapt?
Sass deprecations (import, global-builtin, slash-div, color-functions, if-function)Allow themes that have not yet migrated to @use/@forward to compile cleanly.Remove them once all themes are migrated via mgs-migrate-sass.
Webpack performance hints in dev/watch modeAsset sizes are meaningless before minificationNo — hints are shown correctly in yarn build and fully in yarn build:verbose
imagemin-gifsicle dropped entirelyBinary installer incompatible with Node 18+; package unmaintained since 2019No — GIF assets are copied unoptimised
@typescript-eslint/no-explicit-any offTheme codebase has widespread any usageYes — gradually replace any with proper types in new code

Troubleshooting

CSS not injecting via BrowserSync

  • Verify you are accessing the BrowserSync URL (with port), not the Magento URL directly
  • Check the proxy target in gulp/config/browserSync.js matches your local domain
  • Ensure CSS files are being generated in the correct web/css/ directory

"Module not found" errors

  • Check tsconfig.json paths — the parent theme path must match the actual relative location
  • Verify the parent theme is present at vendor/creativestyle/<parent-theme>/
  • Run yarn install to ensure all builder dependencies are installed

Stale webpack cache after branch switch

yarn gulp cleanWebpackCache

Run this after switching branches with major config differences or after changing webpack aliases — the persistent cache does not detect alias changes automatically.

[DEP0060] util._extend deprecation during yarn serve

Cause: BrowserSync depends on http-proxy (unmaintained since 2020) which uses the deprecated util._extend API. Surfaces on Node.js 22+.

Impact: None — yarn serve works correctly. Cosmetic noise only. Open upstream: BrowserSync issue #2091.


Further reading

版本与发布记录

@creativestyle/magesuite-frontend-builder 共发布 71 个版本,首次发布于 2018/11/13;过去 12 个月发布了 4 个版本。

版本发布日期距今
5.1.0latest2026/10/2120 天前
5.0.12026/06/184 个月前
5.0.02026/06/154 个月前
4.0.22025/11/1911 个月前
5.0.0-beta.8beta2025/09/101.2 年前
5.0.0-beta.72025/09/101.2 年前

关于 @creativestyle/magesuite-frontend-builder 的常见问题

@creativestyle/magesuite-frontend-builder 是什么?

A modern build system for Magento 2 / MageSuite themes built on Webpack 5, TypeScript, and Gulp 5. Provides webpack bundling, SCSS compilation, asset copying, image optimisation, linting, BrowserSync dev proxy, and Magento cache management — a

如何安装 @creativestyle/magesuite-frontend-builder?

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

@creativestyle/magesuite-frontend-builder 支持 TypeScript 吗?

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

@creativestyle/magesuite-frontend-builder 支持 ESM 还是 CommonJS?

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

@creativestyle/magesuite-frontend-builder 需要什么版本的 Node.js?

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

@creativestyle/magesuite-frontend-builder 可以商用吗?

@creativestyle/magesuite-frontend-builder 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@creativestyle/magesuite-frontend-builder 的下载量有多少?

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

@creativestyle/magesuite-frontend-builder 还在维护吗?

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