web-infra-dev / rsdoctor

A one-stop build analyzer for Rspack and webpack.
https://rsdoctor.dev/
MIT License
458 stars 40 forks source link

[Bug]: less file yields ModuleParseError with @ import #476

Open Yexiaoxing opened 3 months ago

Yexiaoxing commented 3 months ago

Version

System:
    OS: macOS 14.6.1
    CPU: (10) arm64 Apple M2 Pro
    Memory: 78.92 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Browsers:
    Edge: 127.0.2651.105
    Safari: 17.6
  npmPackages:
    @rsdoctor/webpack-plugin: ^0.3.11 => 0.3.11

Details

When there is a less file and MiniCssExtractPlugin + less-loader configured, the error will show:

ERROR in ../styles/page.less
Module build failed (from ../node_modules/@rsdoctor/core/dist/inner-plugins/loaders/proxy.js):
ModuleParseError: Module parse failed: Unexpected character '@' (1:0)
File was processed with these loaders:
 * ../node_modules/@rsdoctor/core/dist/inner-plugins/loaders/proxy.js
 * ../node_modules/@rsdoctor/core/dist/inner-plugins/loaders/proxy.js
You may need an additional loader to handle the result of these loaders.
> @import "../node_modules/normalize.css/normalize.css";

seems like the less-loader is not taking effect.

Reproduce link

https://stackblitz.com/edit/github-uloart

Reproduce Steps

npm run build
easy1090 commented 3 months ago

I got this issue, I try to reproduce this problem and fixed it.