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

@akashacms/stacked-dirs

v0.8.4

Published

Automatically watch for changes in stacked directories

Downloads

95

Readme

Automatically watch for changes in stacked directories

In applications like static website generators, it is desired to include a dynamic builder/previewer/watcher mode to automatically rebuild the website every time a file changes. When a new file is added, or if an existing file is changed, or if an existing file is deleted (unlinked), some or all of the website must be rebuilt. Then for full enjoyment, once the rebuild finishes a web browser tab can be automatically reloaded. That way an author can be editing their file, type COMMAND-S to save the file, and automatically a good quality preview shows up in a web browser.

The @akashacms/stacked-dirs package was created to serve that purpose within the AkashaCMS ecosystem. This package was designed to independent enough to be used by any other package, because there is no dependency on the rest of AkashaCMS.

The concept of Stacked Directories comes from AkashaCMS. For each type of file used in a website project -- documents, assets, layout templates, other templates -- we probably want to assemble those files from multiple sources, and we might want one source to be used in one directory path, another in another path, and so on.

For example Assets are a kind of file that in AkashaCMS are simply copied (no modification) into the output directory. The website might use several JavaScript libraries, like Bootstrap and jPopper, each of which come from separate npm packages. Hence you'll end up using these sets of files

  • node_modules/bootstrap/dist would be used at /vendor/bootstrap
  • node_modules/bootstrap-icons would be used at /vendor/bootstrap-icons
  • node_modules/popper.js/dist would be used at /vendor/popperjs

That's simple enough, we're copying files from several directories into corresponding specific directories in the rendered output directory. What's the big deal? Wait, that's not all Stacked Directories does.

Another feature is overriding the files in a directory stack. To understand consider a different scenario, namely the templates. Your static website generator could have several modules for adding functionality. For example one module could implement blogging functionality, and among the templates it supplies is one for constructing River of News displays. Another module could be a theme, and it could override the template for River of News display. And your website could have its own customized River of News template.

With Stacked Directories, the template directory from each plugin module is added to the templates directory stack. When looking for a specific template, the first instance found in the directory stack is what's used.

The final feature is that Stacked Directories automatically watches for updates to every directory, and emits add, change and unlink events as appropriate. It also accounts for all the concerns named with the other two features.

With Stacked Directories you have a leg up on building your own static website generator. To prove this, the source code repository includes an example extremely simplified static website generator.