43081j / postcss-lit

PostCSS syntax for extracting CSS from template literals inside JS/TS files
84 stars 6 forks source link

Allow to customise built-in babel config #44

Closed iSokrat closed 1 year ago

iSokrat commented 1 year ago

Based on this discussion: https://github.com/43081j/postcss-lit/issues/13#issuecomment-1413365189

We need to have ability to somehow overwrite built-in configuration for babel. Without this we can't apply postcss-lit for the files, where, for example, different approach for decorators in js is used.

iSokrat commented 1 year ago

@43081j Could you please take a look?

43081j commented 1 year ago

so sorry i've taken a while to get to this @iSokrat

its been a busy couple of weeks.

off the top of my head, there isn't anywhere in postcss config to pass plugin settings. so it may end up i need to contribute back upstream to postcss, or we put the config elsewhere (e.g. package.json).

ill have a look at it this week for sure

43081j commented 1 year ago

just to update, this is more difficult than expected.

basically i was wondering if we can just auto-detect a babelrc and load that. but the babel module which does that produces a different structure than what the babel parser needs.

it may be we just have an extra section in the postcss config or package.json.

iSokrat commented 1 year ago

@43081j How do you see this may look via postcss config? Do you already have some POC?

43081j commented 1 year ago

i think whichever file we put it in, we'll need logic (e.g. through cosmiconfig or postcss-load-config) to pull the relevant config file in. then look in there for some custom property like lit: {babelOptions: {...}}.

we don't already get access to the config so its likely upto us to read it in like that

iSokrat commented 1 year ago

Okay, let's then review the total result, thanks.

iSokrat commented 1 year ago

@43081j Hello, any updates regarding this issue?

43081j commented 1 year ago

there you go, i have implemented it in #45

sorry it took so long, i have had a lot to work on this month.

iSokrat commented 1 year ago

No worries, everything is fine

43081j commented 1 year ago

ill see if i can get it merged and released this weekend 👍

thanks a lot for the suggestion too

iSokrat commented 1 year ago

Hello @43081j . I think this change is not available on NPM. Will you publish this change there?

43081j commented 1 year ago

@iSokrat published 1.1.0

let me know if it works for you 👍

you can find an example in the bottom of the readme