webpack-contrib / stylus-loader

:art: A stylus loader for webpack.
MIT License
498 stars 99 forks source link

The Stylus plugin passed in through `stylusOptions.use` will be lost during recompilation #424

Closed zavierkolten closed 2 months ago

zavierkolten commented 2 months ago

Bug report

When I add a stylus plugin to stylusOptions.use and run webpack in dev mode. At startup, everything is normal. However, after I change the code and trigger recompilation, the plugin in stylusOptions.use are gone, which leads to a build failure.

Actual Behavior

Due to the lack of plugins, the Stylus function I defined is not imported, resulting in the generated product not being correctly recognized by the css-loader.

Expected Behavior

During recompilation, the plugin in stylusOptions.use can still be found.

How Do We Reproduce?

repository: https://github.com/zavierkolten/stylus-loader-debug branch: main

  1. Install dependencies and run
    pnpm i
    pnpm dev
  2. You can check "dist/main.css" to see if the output is normal
  3. Make some changes randomly in the 'src/foo.styl' file to trigger recompilation
  4. For easy viewing, I used pnpm patch to add a line of console.log to "stylus-loader/dist/index.js"

    image

    First time:

    image

    After recompiling:

    image

Please paste the results of npx webpack-cli info here, and mention other relevant information

System:
    OS: macOS 14.5
    CPU: (11) arm64 Apple M3 Pro
    Memory: 92.33 MB / 18.00 GB
  Binaries:
    Node: 18.20.2 - ~/Library/Caches/fnm_multishells/35160_1726582759694/bin/node
    Yarn: 1.22.22 - /usr/local/bin/yarn
    npm: 10.5.0 - ~/Library/Caches/fnm_multishells/35160_1726582759694/bin/npm
  Browsers:
    Chrome: 127.0.6533.88
    Edge: 128.0.2739.79
    Safari: 17.5
  Packages:
    css-loader: ^7.1.2 => 7.1.2 
    stylus-loader: ^8.1.0 => 8.1.0 
    webpack: ^5.94.0 => 5.94.0 
    webpack-dev-middleware: ^7.4.2 => 7.4.2