Yarn build 'Failed because of a stylelint error'

Sage, Bedrock, Trellis @ latest head

Yarn build fails when I create a new folder with an scss file (with some css content) within resources/assets/styles (for example settings/_settings.scss)

Error message:

yarn build                                             [15:37:33]
yarn run v1.5.1
$ webpack --progress --config resources/assets/build/webpack.config.js
Error: Failed because of a stylelint error.

    at linterSuccess (/local_path/staging.mysite.nl/web/app/themes/mytheme/node_modules/stylelint-webpack-plugin/lib/run-compilation.js:31:14)
    at <anonymous>
error An unexpected error occurred: "Command failed.
Exit code: 1
Command: sh
Arguments: -c webpack --progress --config resources/assets/build/webpack.config.js
Directory: /local_path/staging.mysite.nl/web/app/themes/mytheme
Output:
".

When the new scss file is completely empty, no build error occurs. Whenever I put some valid css in it (no matter how much or little), the build fails.

It also fails with or without a reference in main.scss to the new scss file.

Actually, build also fails when I put some css in an existing (empty) scss file like layouts/_footer.scss
A Sage 9 beta 4 theme in the same website builds just fine.

Running yarn start should give you more details about the error either in the browser window or in the terminal output. Can you try that?

2 Likes

Thx, I assumed yarn start woudn’t work if a build failed. The error turned out to be a css no-descending-specificity in another css file I copied over from a beta 4 theme. I guess that’s a new linter rule since beta 4. All’s fine now.

There are a lot of new linter rules since beta. I never knew how messy my CSS was until @ben started shaming me about it in my terminal.

2 Likes

Lol, so true. Not quite the sass jedi I thought I was.