|
1 | 1 | # html-to-app |
2 | 2 | Convert HTML flat file sites to Apps |
| 3 | + |
| 4 | +## Installation |
| 5 | + |
| 6 | +` |
| 7 | +npm i -g StatelessSoftware/html-to-app |
| 8 | +` |
| 9 | + |
| 10 | +## Preparation |
| 11 | + |
| 12 | +You should have a flat-file html site, and possibly an app directory containing your app (the code will be merged with the build on each run). |
| 13 | + |
| 14 | +If you would like to customize the build, create a config file by typing: |
| 15 | + |
| 16 | +` |
| 17 | +html-to-app -c |
| 18 | +` |
| 19 | + |
| 20 | +## Usage |
| 21 | + |
| 22 | +To build your app, simply type: |
| 23 | + |
| 24 | +` |
| 25 | +html-to-app |
| 26 | +` |
| 27 | + |
| 28 | +### Force a new build |
| 29 | + |
| 30 | +To clean the build and rebuild, run |
| 31 | + |
| 32 | +` |
| 33 | +html-to-app -f |
| 34 | +` |
| 35 | + |
| 36 | +### Configuration |
| 37 | + |
| 38 | +The configuration consists of 4 top-level build-chain objects: importer, converter, builder, and exporter. All paths are relative to the current working directory. Filenames do not contain the directory, as it is deduced from it's parent build-chain object. |
| 39 | + |
| 40 | +## Importer |
| 41 | + |
| 42 | +- **dirHTML** - The location of the HTML flat-files, relative to the current working directory. |
| 43 | +- **dirImages** - The location of asset images in the flat-file site. |
| 44 | +- **dirCSS** - The location of css (css, less, sass, etc) files to copy |
| 45 | +- **dirJS** - The location of js (js, ts, etc) files to copy |
| 46 | +- **typeCSS** - The type of CSS to copy to the build (css, scss, less, etc) |
| 47 | +- **typeJS** - The type of JS to copy to the build (js, ts, etc) |
| 48 | +- **layoutFile** - The location of the HTML layout file. |
| 49 | +- **ignoreViews** - An array of HTML filenames to skip. |
| 50 | +- **precmd** - A shell command to be run before the importer. |
| 51 | +- **postcmd** - A shell command to run after the importer. |
| 52 | + |
| 53 | +## Converter |
| 54 | + |
| 55 | +- **layout** |
| 56 | + - **target** DOM string pointing to the html content of the page. Normally should be document.documentElement.outerHTML to grab the entire document |
| 57 | + - **remove** Query selector to match elements to remove. i.e. "script, #hello, .mine" will remove all `script` tags, any element with the ID `hello`, and any element with the class `mine` |
| 58 | + - **prepend** - String to prepend to the document. Default for layouts should be the document type, as this is stripped in the target process. |
| 59 | + - **append** - String to append to the document |
| 60 | + - **remap** - Array of remaps. Remaps "remap" the folder structure of tags in your HTML files to resemble the build. |
| 61 | + - **tag** - Tag to match |
| 62 | + - **from** - String or regex to replace the href or src from |
| 63 | + - **to** - String to replace the href or src to |
| 64 | + - **prepend** - A string to prepend to the path |
| 65 | + - **append** - A string to append to the path |
| 66 | +- **view** |
| 67 | + - **target** DOM string pointing to the html content of the view. Normally should be document.body.innerHTML to grab only the `<body>` inner |
| 68 | + - **remove** Query selector to match elements to remove. i.e. "script, #hello, .mine" will remove all `script` tags, any element with the ID `hello`, and any element with the class `mine` |
| 69 | + - **prepend** - String to prepend to the document. Default for layouts should be the document type, as this is stripped in the target process. |
| 70 | + - **append** - String to append to the document |
| 71 | + - **remap** - Array of remaps. Remaps "remap" the folder structure of tags in your HTML files to resemble the build. |
| 72 | + - **tag** - Tag to match |
| 73 | + - **from** - String or regex to replace the href or src from |
| 74 | + - **to** - String to replace the href or src to |
| 75 | + - **prepend** - A string to prepend to the path |
| 76 | + - **append** - A string to append to the path |
| 77 | +- **precmd** - Shell command to run before the convert |
| 78 | +- **postcmd** - Shell command to run after the convert |
| 79 | + |
| 80 | +## Builder |
| 81 | + |
| 82 | +- **dirBuild** - Build directory |
| 83 | +- **installCmd** - Command to install the app (e.g. `express`) |
| 84 | +- **cleanupCmd** - Command to run after the app installs (inside the build directory) |
| 85 | +- **precmd** - Shell command to run before the build |
| 86 | +- **postcmd** - Shell command to run after the build |
| 87 | + |
| 88 | +## Exporter |
| 89 | + |
| 90 | +- **dirBuild** - Export directory (can be seperate from the build directory) |
| 91 | +- **dirMerge** - App directory to merge with the build |
| 92 | +- **dirViews** - Directory to export views to (inside the build) |
| 93 | +- **dirImages** - Directory to copy images to (inside the build) |
| 94 | +- **dirCSS** - Directory to copy css to |
| 95 | +- **dirJS** - Directory to copy js to |
| 96 | +- **viewExtension** - Extension to convert the views to |
| 97 | +- **precmd** - Shell command to run before the export |
| 98 | +- **postcmd** - Shell command to run after the export |
0 commit comments