Yogesh Chauhan's Blog

Solution for “Yarn build: Failed because of a stylelint error”

in WordPress on April 7, 2021

Recently, I was going through installation of Laravel and mixing it with WordPress. It’s pretty simple with Sage theme and you can install the CSS frameworks like Tailwind, Bootstrap and others.

The errors occur when you try to build it using yarn.

After initial installation, we can just use yarn to make sure we have all the required dependencies installed and use yarn build to build the app.

What yarn build does is it compiles and optimizes the files in your assets directory.

In simple words, when you add some code in your .scss files and try to compile it, it might throw this error:


yarn run v1.22.10
$ webpack --progress --config resources/assets/build/webpack.config.js
Error: Failed because of a stylelint error.

    at /Users/yogeshchauhan/folder-1/WordPress-directory/wp-content/themes/sage/node_modules/stylelint-webpack-plugin/lib/run-compilation.js:39:14
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The fix is in these 4 lines as you can see on GitHub Sage Theme Repo as well.


 new StyleLintPlugin({
    failOnError: !config.enabled.watcher,
    syntax: 'scss',
 }),

COMMENT THOSE 4 LINES ABOVE from /resources/assets/build/webpack.config.js and it should fix your problem.

Just like this:


Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to add Read More Read Less Button using JavaScript? #4 How to uninstall Cocoapods from the Mac OS? #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#Aug 15 Is PHP still good for back-end programming? #Aug 10 How to create a multisite network in WordPress? #Aug 3 How to create a circle that follows a cursor using JavaScript and CSS? #Aug 3 How to make a curtain slider using jQuery and CSS? #Aug 2 How to progressively load images and add a blurry placeholder? #Aug 1 How to create a placeholder loader (throbber) using CSS?
You might also like these
How to use @each rule with key-value pair in SCSS?SCSSHow to Use password_hash and password_verify to Secure Your User’s Data (Especially Passwords)?PHPHow to create a simple text and image slider using CSS and JavaScript?CSSWhat are Identifiers in JavaScript?JavaScriptArguments in @mixin rules in SCSS (Sass)SCSSHow to select multiple values in React dropdown?React