1.0.10 β€’ Published 1 year ago

html-inline-external-without-cdn v1.0.10

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

html-include-external-resources

Simple utility to inline external HTML resources from <script> <links /> <img /> into single HTML file.

npm PRs Welcome

Features

  • Full Control over output configuration, Print to console πŸ’», Write to file πŸ“ or simply Copy to clipboard πŸ“‹ .
  • Converts and inlines πŸ–Ό source into base64 stringπŸ€“.
  • Configurable html tags to be processed πŸ› .
  • Node API
Contents
CLI Usage
Node API Usage
Recipies

CLI Usage

npx html-inline-external --src index.html >> output.html 

Input:

index.html

<html>
    <head>
        <script type="text/javascript" src="./index.js"></script>
        <link rel="stylesheet" href="styles.css">
    </head>
    <body>
        Hello World
    </body>
</html>

index.js

alert("This is an alert!")

styles.css

body {
    background-color: black;
    color: white;
}

Output:

> npx html-inline-external --src ./index.html >> output.html

output.html

<html>
  <head>
    <script type="text/javascript">
      alert("This is an alert!")
    </script>
    <link rel="stylesheet" href="styles.css">
    <style>
      body {
        background-color: black;
        color: white;
      }
    </style>
  </head>
  <body>
    Hello World
  </body>
</html>

Options :

OptionDefaultDesscription
srcN/APath to the source file
destN/APath to the destination file
tagsscript, link, imgList HTML Tags to be processed in csv format
copyfalseCopies the process output to clipboard
prettyfalsePrettify output
minifyfalseMinify output

Node API Usage

  • Install html-inline-external using your package manager
npm install html-inline-external --save 

OR

yarn add html-inline-external
  • Use it in your NodeJS file
htmlInlineExternal({options})
  • Example
const htmlInlineExternal = require('html-inline-external')

htmlInlineExternal({src: './test/index.html'}).then(output => console.log(output))

API Options :

OptionDefaultDesscription
srcN/APath to the source file
tagsscript, link, imgList HTML Tags to be processed in csv format
prettyfalsePrettify output
minifyfalseMinify output

Recipies

Write output to file:

Uses node fs and writes the output into the given file path

> npx html-inline-external --src ./index.html --dest ./output.html 
> [Log] Wrote to file output.html. 

Copy processed output to clipboard:

Copies the processed output to clipboard, Could be accessed by simply hitting Ctrl/Cmd + V

> npx html-inline-external --src ./index.html --copy 
> [Log]: Copied to clipboard. 

Prettify processed output:

Prettifies the processed output

> npx html-inline-external --src ./index.html --pretty --dest ./output.html 
> [Log] Wrote to file output.html 

Minfy processed output:

Minifies the processed output to remove whitespaces

> npx html-inline-external --src ./index.html --minify --dest ./output.html 
> [Log] Wrote to file output.html