Let webpack print individual compiled files except the package

I am using the webpack ts-loader to compile typescript source files into a javascript set. Now, I would like individually compiled javascript files to be saved as well as a collection! I am familliar with writing a very simple webpack plugin, but I'm not sure how to implement this. That is: I do not know what events were triggered using webpack to listen and where to find the relevant data. Any help?

+5
source share
1 answer

As I said, you cannot use compiled individual files using webpack. It may break with Uncaught ReferenceError: __webpack_require__ is not defined .

It is better to write your own loader or ask ts-loader provide the ability to save the transmitted source.

Or I wrote a loader that can save compiled typescript files as separate files.

You can use the second bootloader or post loader as shown below.

as a second bootloader:

 module: { loaders: [{ test: /\.ts?$/, loaders: ['scatter-loader', 'ts-loader'] }] } 

or as a post loader

 module: { loaders: [{ test: /\.ts?$/, loaders: ['ts-loader'] }], postLoader: [{ test: /\.ts?$/, loaders: ['scatter-loader'] }] } 

Note: scatter-loader is working.

+2
source

Source: https://habr.com/ru/post/1261689/


All Articles