'Bundling a simple static html file and its dependencies in a single html

I have a relatively simple static html file that has a few external dependencies (e.g. an external CSS stylesheet, or a few images).

Is there some tool (preferably node.js based) that will allow me to programmatically "bundle" everything up as a single html file? So for example, this tool would do things like:

  • Convert <link rel="stylesheet" href="..."> into <style>
  • Convert images into data-uri images
  • etc

Can webpack do something like that (with the use of appropriate plugins)?

Note: I am aware that some browsers can bundle everything into an MHTML file but I am looking for a tool that can be invoked programmatically and which produces (preferably) a pure html file.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source