developit / microbundle

📦 Zero-configuration bundler for tiny modules.
https://npm.im/microbundle
MIT License
8.06k stars 361 forks source link

LESS complie issue #786

Open Chris-LuYi opened 3 years ago

Chris-LuYi commented 3 years ago

I have encounter this error when try to compile my less file (postcss plugin) Error: Inline JavaScript is not enabled. Is it set in your options?

after exploring, find a solution to add config in my local microbundle file like below image

is there a way to config it through configuration?

developit commented 3 years ago

Hi @Chris-LuYi - I believe this should be possible by providing a postcss.config.js file, though I haven't tested it myself. Just as a heads-up, we're considering removing LESS support from Microbundle as part of an effort to focus on bundling npm modules. If you're using Microbundle to bundle a website, you might find wmr more suitable - it supports Rollup plugins, which should mean it's fairly straightforward to add a custom LESS processor.

Chris-LuYi commented 3 years ago

Hi @Chris-LuYi - I believe this should be possible by providing a postcss.config.js file, though I haven't tested it myself. Just as a heads-up, we're considering removing LESS support from Microbundle as part of an effort to focus on bundling npm modules. If you're using Microbundle to bundle a website, you might find wmr more suitable - it supports Rollup plugins, which should mean it's fairly straightforward to add a custom LESS processor.

Hi @developit , I tried add rollup.config and postcss.config in my project but seems not reading when run my microbuddle scirpt. Actually I am using microbuddle for my own package publishing, but it use antd which require less compliation, if I want to bundle my final application I can use wmr or webpack.

developit commented 3 years ago

Microbundle doesn't support custom Rollup configuration - allowing that would make it impossible to provide an upgradable preconfigured system.

FWIW there shouldn't be a reason to compile the less from antd just to use it as a dependency. It sounds like you might be inadvertently compiling antd into your module, which is generally not a desirable outcome since it leads to excessive duplication and breaks versioning. If your needs support it, I'd recommend listing antd in "dependencies", which will preserve imports for that library in bundled code rather than inlining all of it.

Chris-LuYi commented 3 years ago

Ya, by right I don't need to import LESS files from antd, because I am using the same less variable from antd try to make standard styling that's why I need it. Anyways thanks, I will figure another way to solve it.

On Sat, 16 Jan 2021 at 00:37, Jason Miller notifications@github.com wrote:

Microbundle doesn't support custom Rollup configuration - allowing that would make it impossible to provide an upgradable preconfigured system.

FWIW there shouldn't be a reason to compile the less from antd just to use it as a dependency. It sounds like you might be inadvertently compiling antd into your module, which is generally not a desirable outcome since it leads to excessive duplication and breaks versioning. If your needs support it, I'd recommend listing antd in "dependencies", which will preserve imports for that library in bundled code rather than inlining all of it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/developit/microbundle/issues/786#issuecomment-761047969, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFA6JAKOXJ3L23THERWG4B3S2BVMFANCNFSM4WB4T2MQ .

dukeliberal commented 3 years ago

Hi @Chris-LuYi - I believe this should be possible by providing a postcss.config.js file, though I haven't tested it myself. Just as a heads-up, we're considering removing LESS support from Microbundle as part of an effort to focus on bundling npm modules. If you're using Microbundle to bundle a website, you might find wmr more suitable - it supports Rollup plugins, which should mean it's fairly straightforward to add a custom LESS processor.

Can we support it using postcss.config.js ? I test it using the config file, but it doesn't work, seems microbundle OR postcss doesn't read the file.