arackaf / customize-cra

Override webpack configurations for create-react-app 2.0
MIT License
2.78k stars 269 forks source link

Will an addWebWorkerLoader() be welcomed? #223

Open Menci opened 4 years ago

Menci commented 4 years ago

The method to add web workers is a little complex. I finally figured out the way to chain the CRA's Babel loader and WebWorker loader:

https://github.com/syzoj/syzoj-ng-app/blob/7e8896bfd0205b8f815cca1333edeafa18d27d89/react-app-rewired.js#L88

Will my request be welcomed?

caperso commented 4 years ago

big lao, I found a way to fullfill this proposal, in https://github.com/facebook/create-react-app/issues/3660 like

addWebpackModuleRule({ test: /\.worker\.js$/, use: { loader: "worker-loader" }, }),

Menci commented 4 years ago

@caperso We should chain babel-loader with worker-loader to compile the scripts. So I created the rule based on the default .tsx loader's rule.