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

static-pages-bundler

v1.0.25

Published

This is a simple library that creates a bundle of a simple web page that uses classic `<link ...>` and `<script ...>` way to connect a bunch of CSS and JS files to the HTML template.

Downloads

45

Readme

About

What is static-pages-bundler

This is a simple library that creates a bundle of a simple web page that uses classic <link ...> and <script ...> way to connect a bunch of CSS and JS files to the HTML template.

An entry point is your index.html. All the connected CSS, JS found by their paths in the index.html. Then the data parsed and compressed into three files: index.html, bundle.css and bundle.js.

Watch on YouTube

static-pages-bundler uses html-minifier, uglify-es and uglifycss as dependencies.

! Important notes

For now static-pages-bundler tested only on macOS Movaje v10.14.4, Windows 7 Enterprise and Ubuntu 18.04.2 LTS.

Basic usage

Video tutorial

Watch on YouTube

Installation

To use the library you will need to have node.js and git installed on your system.

To install static-pages-bundler globally, simply run from terminal:

  $ npm install -g static-pages-bundler

You may remove the -g flag if you want to install static-pages-bundler as a dev dependency. So, the command will be

  $ npm i --save-dev static-pages-bundler

Bundling process

  1. Create a dist folder you're going to run the script from. You may skip the step, but in the case, you will have to run static-pages-bundler using sudo to give the bundler permissions to create that folder structure for you (running npm libs with sudo is never recommended with any third party lib).

  2. In your HTML template setup the entry points for the bundler:

    2.1. Wrap your <link ...> elements that have CSS files imports via CSS comments:

        <!-- Bundler CSS start -->
          ... your <link ...> elements
        <!-- Bundler CSS end -->

    2.2. Wrap your <script ...> elements that have JS scripts via JS comments:

        <!-- Bundler JS start -->
          ... your <script ...> elements
        <!-- Bundler JS end -->

    ! Its important to use exact same comment lines

        <!-- Bundler CSS start -->,
        <!-- Bundler CSS end -->,
        <!-- Bundler JS start --> and
        <!-- Bundler JS end -->.

    ! Also, please use only one entry point for CSS and one for JS. The library doesn't work with multiple entry points for now.

  3. Using terminal go to the location where your index.html located and run:

      $ static-pages-bundler

    You can use the next shortcut instead of full static-pages-bundler:

      $ spb

    Also, if the name of your HTML template is not index.html you can specify it in the command eg:

      $ spb <your-html-template>
  4. As a result: Your HTML will be added to dist/<filename>.html. Your CSS will be compressed to dist/bundle.css. Your JS will be compressed to dist/bundle.js. All your <link and <script> lines that were wrapped info CSS and JS comment lines will be replaced with <link rel="stylesheet" href="bundle.css"> and <script src="bundle.js" defer></script>.

  5. If you use any assets, then copy folder with them into a place where your new bundle will have access (same relative path as they had previously). static-pages-bundler doesn't change any links/paths inside your code, so please, make sure all the paths work (paths to images, icons, fonts, etc.).