We choose to use Browserify to modularize our CoffeeScript, because we love the idea of being able to use Node modules in the browser. While Browserify is a very powerful tool, we still needed a build tool in order to integrate Browserify into our build process.
We explored existing Browserify tools, but found no tool that met our requirements. Watchify—which allows you to pass in an input file and Browserifies the file to an output location—was close to meeting our needs, but would require us to launch a new Watchify instance for every new file we created. This is very ineffecient when you are dealing with a site like ours which has dozens of CoffeScript files. We realized what we needed was one command that would watch every file in our CoffeeScript directory, browserify a file on any file change or file addition, and output the file to a specified directory
Since we didn’t see any Browserify tools that met our needs, we decided to build Browserify Directory to solve our own problem. You can think of Browserify Directory as a supercharged Watchify tool for Browserify. Browserify Directory:
- Watches all files in an input directory as well as their dependencies and bundles the files to an output directory on file change or dependency change.
- Mirrors the file and folder structure in the input directory to the output directory.
- Automatically works its watching magic on any new files that are added in the input directory.
We have already integrated Browserify Directory in the entire Muse site. So check it out and start using it in your Browserify build process.
Photo of wizard hat courtesy of Shutterstock.
TopicsEngineering @ The Muse
As a full-stack engineer, Shlomo spends his time building the latest interactive features that you see on The Muse. A Michigan grad (Go Blue!), he led student teams consulting for Israeli startups and interned with Onavo (in Tel Aviv) and the Barbarian Group before beginning to Muse right after he graduated. When he isn’t Musing, he can usually be found cooking some of the best hamburgers in NYC.More from this Author