Skip to content

docs: document postinstall copy-out workaround for shopware-cli #1466 - #2487

Draft
Soner (shyim) wants to merge 1 commit into
mainfrom
docs/storefront-build-postinstall-npm-workaround
Draft

docs: document postinstall copy-out workaround for shopware-cli #1466#2487
Soner (shyim) wants to merge 1 commit into
mainfrom
docs/storefront-build-postinstall-npm-workaround

Conversation

@shyim

Copy link
Copy Markdown
Member

Documents the known workaround from shopware/shopware-cli#1466 so theme authors can keep using npm packages (e.g. @fortawesome/fontawesome-free) from SCSS while the upstream fix is still open.

Problem

shopware-cli project storefront-build fails for a pure-SCSS theme that imports from node_modules because:

  • it only runs npm install for storefront extensions with a JS entry point, and
  • even with a main.js, the storefront-root node_modules is removed before theme:compile runs.

Changes

  • New section "Using npm packages in a pure-SCSS theme (no JS entry point)" in guides/plugins/plugins/dependencies/using-npm-dependencies.md describing the postinstall copy-out workaround: empty main.js, package.json postinstall that copies SCSS into .vendor/node_modules/... and webfonts into public/static/fonts/, updated theme.json/SCSS paths, and .gitignore entries.
  • Short pointer with anchor link from guides/plugins/themes/styling/add-css-js-to-theme.md so theme authors find the workaround from the theme styling guide.
  • Added webfonts to .wordlist.txt.

Quality

  • make spellcheck passes.
  • make fix (markdown lint) passes.

Refs shopware/shopware-cli#1466.

@shopware-dev-docs-connector

shopware-dev-docs-connector Bot commented Aug 31, 2026

Copy link
Copy Markdown

Developer Docs healthcheck

Status: Completed with success.
Repository: shopware/docs
Commit: fe96932
Preview: https://developer-documentation-nlg130rnx-shopware-frontends.vercel.app
Workflow run: #5107

A pure-SCSS theme that imports from `node_modules` (e.g. @fortawesome/fontawesome-free)
fails `shopware-cli project storefront-build` because the storefront-root `node_modules`
is deleted before `theme:compile` runs. Document the known `postinstall` copy-out
workaround in the npm dependencies guide and link to it from the theme styling guide,
with a reference to shopware/shopware-cli#1466 for the longer-term fix.
@shyim
Soner (shyim) force-pushed the docs/storefront-build-postinstall-npm-workaround branch from 945e8ea to fe96932 Compare August 31, 2026 11:15

## Using npm packages in a pure-SCSS theme (no JS entry point)

If your plugin is a **theme** and only consumes npm packages from SCSS (for example `@fortawesome/fontawesome-free` or any other package referenced via `@import` in your `theme.json` `style` entries), you will run into a chicken-and-egg problem with `shopware-cli project storefront-build`:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idk I find the chicken-egg wording a bit strange for the docs.

Suggested change
If your plugin is a **theme** and only consumes npm packages from SCSS (for example `@fortawesome/fontawesome-free` or any other package referenced via `@import` in your `theme.json` `style` entries), you will run into a chicken-and-egg problem with `shopware-cli project storefront-build`:
If your plugin is a **theme** and only consumes npm packages from SCSS (for example `@fortawesome/fontawesome-free` or any other package referenced via `@import` in your `theme.json` `style` entries), you will not be able to run `shopware-cli project storefront-build` successfully:


If your plugin is a **theme** and only consumes npm packages from SCSS (for example `@fortawesome/fontawesome-free` or any other package referenced via `@import` in your `theme.json` `style` entries), you will run into a chicken-and-egg problem with `shopware-cli project storefront-build`:

* `shopware-cli` only runs `npm install` for a storefront extension when it has a JavaScript entry point (`src/Resources/app/storefront/src/main.js`).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put this part BEHIND "The result is that a theme.json/SCSS @import like app/storefront/node_modules/@fortawesome/fontawesome-free/scss/fontawesome cannot be resolved, and theme:compile aborts with:".

So the reading is order:

  1. Will not working
  2. Error message
  3. And then the reason (background info) why its not working


Because the `postinstall` script of a storefront extension's `package.json` runs **before** the root `node_modules` directory is deleted, you can copy the parts of the package that `theme:compile` needs into a persistent (git-ignored) folder inside the theme. After that, the SCSS imports and `theme.json` `style` entries must point at that folder instead of `node_modules`.

The nested folder must contain a `node_modules` path segment, because `shopware-cli project format` / `validate` only ignore the storefront-**root** `node_modules` and `shopware-cli` only deletes that one level. A nested copy survives both steps.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if I understand this part. What does nested folder mean? Maybe provide an example?

* `shopware-cli project format` / `validate` do not flag the copied files because they live under a nested `node_modules/` path.
* The webfonts end up under `public/bundles/<theme>/static/fonts/` after compilation, which is what the SCSS expects at runtime.

This workaround is known to be fragile: it depends on `shopware-cli` running npm lifecycle scripts and on the cleanup deleting only the storefront-root `node_modules`. If you do not need npm packages in your theme, prefer keeping the theme free of `node_modules` imports. A longer-term fix (installing npm dependencies for a JS-less theme and deferring the `node_modules` cleanup until after `theme:compile`) is being discussed in [shopware/shopware-cli#1466](https://github.com/shopware/shopware-cli/issues/1466).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can also point to the normal asset adding workflow here as an alternative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants