symfony / webpack-encore-bundle

Symfony integration with Webpack Encore!
https://symfony.com/webpack-encore
MIT License
933 stars 83 forks source link

Custom rule error: ModuleBuildError involving postcss-loader, which I'm not using? #192

Closed gremo closed 2 years ago

gremo commented 2 years ago

I'm trying to add a custom rule, which should use only style-loader and css-loader. This rule will be activated with .css files and when resource query is "uncritical", i.e. mystyle.css?uncritical:

.addLoader({
  test: /\.css$/,
  resourceQuery: /uncritical/,
  use: [
    {
      loader: 'style-loader',
      options: {
        injectType: "lazyStyleTag",
        insert: "body"
      }
    },
    'css-loader'
  ]
})

Then in app.js:

import styles from '@fortawesome/fontawesome-pro/css/fontawesome.css?uncritical';

Syntax Error: ModuleBuildError: Module build failed (from ./node_modules/postcss-loader/dist/cjs.js): SyntaxError

(1:1) node_modules\@fortawesome\fontawesome-pro\css\fontawesome.css > Unknown word

1 | import api from "!../../../style-loader/dist/runtime/injectStylesIntoStyleTag.js"; | ^ 2 | import content from "!!../../../css-loader/dist/cjs.js!./fontawesome.css?uncritical"; 3 |

I can't understand why postcss-loader is being used here. Any help is much appreciated.

gremo commented 2 years ago

Well, closing because I messed up with addLoader and addRule.