css-declaration-sorter: TypeError: Cannot read property 'insertAfter' of undefined

Hi, I keep getting this error. I did “yarn cache clean” Reinstalled everything and still cannot figure out why this is failing.

Done in 38.91s.
Compiling...
Compilation failed:
warning package.json: No license field
TypeError: Cannot read property 'insertAfter' of undefined
    at node_modules/optimize-css-assets-webpack-plugin/node_modules/css-declaration-sorter/src/main.cjs:372:22
    at Array.forEach (<anonymous>)
    at processCss (node_modules/optimize-css-assets-webpack-plugin/node_modules/css-declaration-sorter/src/main.cjs:369:12)
    at node_modules/optimize-css-assets-webpack-plugin/node_modules/css-declaration-sorter/src/main.cjs:304:21
    at async LazyResult.runAsync (node_modules/optimize-css-assets-webpack-plugin/node_modules/postcss/lib/lazy-result.js:431:15)
    at async Promise.all (index 0)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 35 (14 by maintainers)

Commits related to this issue

Most upvoted comments

I am surprised this bug has been present for so long!

Released a fix in 6.1.2.

I’m having the same issues

Hi @Siilwyn and @thecrypticace ,

This was the dependency that caused this issue: https://github.com/NMFR/optimize-css-assets-webpack-plugin/issues/168 It’s fixed in 5.0.8 after updating to that dependency to that version, the problem was resolved.

@zfeher @dave105010 you are not using laravel-mix right? If you could provide an example using just webpack (as minimal as possible) that would help me out a ton!

Edit: Cleaned up the thread by hiding some comments which provide no new info, please read the posted replies so far before posting.

Hi Siilwyn,

No, we are on Rails 6 framework so not using laravel-mix. This was fixed after updating the dependencies for me. There was a bug on either this or on something else. They released an update a day later. I can’t remember the details but updating things fixed this for me.

After quite a bit of digging I found the error I was getting was due to RTLCSS control directives in an included SCSS file. Once I removed these the build succeeded without issue.

/*!rtl:begin:ignore*/
grid-column: 1;
/*!rtl:end:ignore*/