glromeo / esbuild-sass-plugin

esbuild plugin for sass
MIT License
155 stars 40 forks source link

How to use this plugin for build Node.js app with css modules? #139

Closed krutoo closed 1 year ago

krutoo commented 1 year ago

Hi, i try to build Node.js app by esbuild with bundle: false.

In my app there is css modules.

In my case i receive valid JS files after build bun with imports from unexisted css modules.

They just weren't created after the build.

How can i use this plugin for build node.js app with creating *.module.scss from*.module.scss.js`?

glromeo commented 1 year ago

When bundle is false esbuild doesn't process the imports and as a consequence it doesn't call the plugin at all. The only thing that I can tell is that If you don't want to bundle then you probably shouldn't use esbuild at all...

krutoo commented 1 year ago

@glromeo but esbuild allows to build application without bundling, why it not allows to run plugins in this mode?

glromeo commented 1 year ago

That's a bit confusing indeed. Bear in mind that the plugin system is purely hooked into the resolve and load steps of the life cycle of the build process. When bundle is false the plugins are called only for the main entry point so anything that's imported is just left as is unless you implement a transformation of the entrypoint itself but then again this means not really using esbuild for what it is... better off with babel or swc

On Wed, 21 Jun 2023, 05:18 Dmitry Petrov, @.***> wrote:

@glromeo https://github.com/glromeo but esbuild allows to build application without bundling, why it not allows to run plugins in this mode?

— Reply to this email directly, view it on GitHub https://github.com/glromeo/esbuild-sass-plugin/issues/139#issuecomment-1600049508, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABHJVMZ4GCRN5JHWBLWGDTXMJYZDANCNFSM6AAAAAAZDZCZXA . You are receiving this because you were mentioned.Message ID: @.***>