swc-loader
swc-loader copied to clipboard
Swc-loader seems to ignore .swcrc.json and/or there's no way to specify a config
When I normally use SWC I call my config .swcrc.json to keep it consistent with tons of other similar configs and so that my IDE can automatically style the JSON, not being able to use .json is a pain.
When normally running swc I use --config-file .swcrc.json
to specify the config, which works fine on most projects. However when using it with swc-loader and webpack, it seems that the config is completely ignored and instead defaults are used. However when calling it ".swcrc" only it seems to work, but I want it to be .json otherwise editing it in IDE looks ugly.
I also don't want to have to duplicate all the configuration to webpack, it's already in .swcrc.json, there shouldn't be any reason to duplicate it in there. Instead swc-loader should be able to read the existing config.
It would be nice if I could use swc-loader and keep my config named what I want it to be named.
Hi, you can do this:
const swcrc = await fs.readFile('swcrcPath', 'utf-8');
...
{
test: /.(t|j)sx?/,
exclude: /(node_modules)/,
use: {
loader: 'swc-loader',
options: {
...JSON.parse(swcrc),
},
},
},
I agree with swc-loader should be able to read the existing config, plz add this feature.