Z
Z
zhna2018-11-11 05:24:36
JavaScript
zhna, 2018-11-11 05:24:36

How to write a plugin for webpack?

Welcome all. There is a task to write a plugin for webpack. The essence of the plugin is to get html, css, js from files with *.myfile extension. And pass them to webpack for further processing.
But I have little idea where to start. And how it's supposed to work.
I spent a couple of days reading the Runet, except for 1 article on Habré on writing a plugin for svg and the "pretty" wepack help, I didn’t find anything. I also don’t know what plugins do such actions to peep (vue-loader but it has a different logic).
How to get data from files and change them using a plugin?
For example, to insert html, I will use some kind of comment in index.html to insert html from file.myfile in its place. I don't know how to do it. As an option, pass my pieces of code separately through all sorts of loaders inside the plugin and overwrite the build files, but then you can forget about hot reload. And yes, I think that's bullshit.
In general, set me on the right path. Poke your nose into the help, well, etc.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question