E
E
Egor Mikheev2019-08-30 14:00:55
Frontend
Egor Mikheev, 2019-08-30 14:00:55

How to precompile a ts file into js using webpack before building a project?

Hello. There is a problem, the solution of which could not be found "quickly"
The essence of the problem.
- Writing a webworker in typescript with its subsequent registration
- Using the workbox library from google and the plugin workbox-webpack-plugin
The build
process The process goes in such a way that the plugin looks for a js file with the definition of webworker and injects workbox into it as a global variable, the plugin strictly accepts input js file.
Suggested Solution
- The only solution that comes up quickly is to separately compile webworker.ts to webworker.js before building the project and then run the webpack build process.
Question:
How can this be done? Are there webpack internals or plugins that will allow you to exclude the worker from the overall build, compile it separately, and then start the main build process? Or do you have to write your own scripts?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alexhovansky, 2019-08-30
@alexhovansky

https://webpack.js.org/concepts/entry-points/#sepa... You
specify several entries, as a result you get several bundles

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question