Skip to content

A CLI tool that extract style and script resources from html

Notifications You must be signed in to change notification settings

changLiuUNSW/html-resource-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NPM Version

html-resource-generator

A CLI tool that extract style and script resources from html

Install

npm install -g html-resource-generator

Usage

hrg -h shows the help:

  Usage
    $ hrg <input>
    Options
      --out, -o      Output file name. Default: manifest.json
      --prefix, -p   Add prefix to the path of external resources
      --help, -h     show help
      --version      show version
    Examples
      $ hrg index.html -o manifest.json

Examples

Assume we have index.html like this:

<!doctype html>
<html lang="en-AU">

<head>
    <link href="/client/dist/styles.d1f7c9f576103c62cb95.bundle.css" rel="stylesheet" />
</head>
<body>
    <script type="text/javascript">
        function inline() {
            console.log('inline');
        }
    </script>
    <script type="text/javascript" src="/client/dist/main.c2e1bcb424c7762ae48a.bundle.js"></script>
</body>
</html>

hrg index.html -o manifest.json gives following manifest.json.

{
  "styles": [
    { "inline": false, "value": "/client/dist/styles.d1f7c9f576103c62cb95.bundle.css" }
  ],
  "scripts": [
    {
      "inline": true,
      "value": "\n        function inline() {\n            console.log('inline');\n        }\n    "
    },
    { "inline": false, "value": "/client/dist/main.c2e1bcb424c7762ae48a.bundle.js" }
  ]
}

hrg index.html -o manifest.json -p myapp gives following manifest.json.

{
  "styles": [
    { "inline": false, "value": "myapp/client/dist/styles.d1f7c9f576103c62cb95.bundle.css" }
  ],
  "scripts": [
    {
      "inline": true,
      "value": "\n        function inline() {\n            console.log('inline');\n        }\n    "
    },
    { "inline": false, "value": "myapp/client/dist/main.c2e1bcb424c7762ae48a.bundle.js" }
  ]
}

Latest Changes

LICENSE

MIT

About

A CLI tool that extract style and script resources from html

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published