npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

html-compiler

v0.1.4

Published

Plain HTML with inlcudes support

Downloads

11

Readme

html-compiler

Plain HTML with inlcudes support. Say what?

Indeed!

html-compiler compiles your HTML adding includes support using special string(s) you add to your HTML.

NOTE: The destination folder, dist by default, is cleaned out with every build. Also, your static assets(images, css, js) are not copied accross by this utility. Because, do one thing and do it well.

For a simple file system command utility in Nodejs, take a look at fs-extra-cli

Tell me more

Inside your HTML document, add the following string where you want to include a file:

#html-include=folder/index.html

The path specified should be relative to the root of your project folder. When you run html-compiler, it will replace the above string with the contents of the file you specified, and write the processed contents to a folder called dist by default.

When including assets, these need to be linked absolutely to avoid problems with nested files and folders when serving your site. html-compiler takes the grunt work out of this with the #html-include-asset string. For exmaple:

<link rel="stylesheet" href="#html-include-asset=/css/libs/prism.css" media="screen" />

When using common incldues such as a navigation menu, one rus into the same problem as with assets, where relative linking will cause the navigation to not function on any nested pages. To remedy this, html-compiler includes the #html-include-link directive. For example:

<li><a href="#html-include-link=/style/color/">Color</a></li>

As with assets, this will cause the above string to be processed prepending the site root to the specified URL.

Have a look at the styleguide folder in this repo for example usage, and see the documentation below for more on the options available.

Install

npm install html-compiler

Usage

From the command line call html-compiler specifying the folder containing the HTML files.

html-compiler --rootFolder=foldername --siteRoot=http://localhost:8000/dist

The preserveRoot option [added in v0.0.4]

Currently, when writing your files to the destination directory, the original root folder is preserved. This is not always desirable. html-compiler now includes a preserveRoot command line parameter to control this behaviour.

If you want to write the contents of your root folder directly to the destination directory, without preserving the root folder, run the command as before.

html-compiler --rootFolder=foldername

If however you wish to preserve the original root, call html-compiler as follows:

html-compiler --rootFolder=foldername ---preserveRoot

The siteRoot argument [added in v0.0.6]

Assets needs to be linked absolutely from the site root, in order to facilitate this, html-compiler uses the string #html-include-asset, for example:

In your HTML

<link rel="stylesheet" href="#html-include-asset=/css/libs/prism.css" media="screen" />

Now call the utility as follows:

html-compiler --rootFolder=styleguide --siteRoot=http://localhost:8000/dist

The dest argument [added in v0.0.8]

Allows you to specify the output directory for processed files. Defaults to dist

html-compiler --rootFolder=styleguide --dest=public --siteRoot=http://localhost:8000/dist