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

uber-compiler

v0.4.7

Published

Compiler for client-side JS and CSS using Google Closure and LESS

Downloads

9

Readme

uber-compiler

The uber compiler compiles your client-side JS and CSS using Google Closure compiler, soy templates and LESS. These are my favourite tools for developing lean webapps.

Features:

  • Google Closure Compiler, Closure Templates, LESS.
  • No need to restart the server. It watches files for changes and then re-compiles as soon as changes are detected.
  • Caches results, so compilation only happens on changes.
  • Compiles on startup unless source files have not changed.

How to use

Install the latest module using NPM:

npm i -g google-closure-compiler
npm i uber-compiler

Alternatively, for manual installation:

git clone https://github.com/kennberg/node-uber-compiler uber-compiler
cd uber-compiler
npm install

In your server.js do this before the service starts (replace paths with your own):

var path = require('path');

var rootPath = process.cwd();
var uberOptions = {
  jsPaths: [
    path.join(rootPath, 'public/js/lib/jquery-1.7.2.js'),
    path.join(rootPath, 'public/js/lib/underscore.js'),
    path.join(rootPath, 'public/js/lib/backbone.js'),
    path.join(rootPath, 'public/js/init.js'),
    path.join(rootPath, 'public/js/model/'),
    path.join(rootPath, 'public/js/view/'),
    path.join(rootPath, 'public/js/router/'),
    path.join(rootPath, 'public/js/main.js')
  ],
  cssPaths: [ path.join(rootPath, 'public/css') ],
  outputDir: path.join(rootPath, 'public/cached'),
  debug: false
};
var uberCompiler = require('uber-compiler')(uberOptions);
uberCompiler.run();

Note that the compiler respects the order of the paths and can handle both files and directories.

The compiler, by default, outputs 'cached.js' and 'cached.css' into outputDir specified in the options. You can include these in the HTML head tag:

<html>
<head>
<script type="text/javascript" src="cached/cached.js"></script>
<link rel="stylesheet" type="text/css" href="cached/cached.css" />
</head>
<body>
  <p>Hello world!</p>
</body>
</html>

Options:

  • jsPaths - array of absolute paths to js/soy files or directories with js/soy files.
  • cssPaths - array of absolute paths to css/less files or directories with css/less files.
  • outputDir - absolute path to where the compiled files will be written.
  • dontWatchFiles - turn off re-compile when files change. Might want to use this in production.
  • debug - true reduces compilation time and only compresses whitespace.
  • useHash - generates dynamic output filenames based on the current options - use getJsFilename() and getCssFilename() methods in your templates.

Advanced options:

  • warningLevel - string used for Closure Compiler to control what warnings to output.
  • compileMode - string specifying the compile mode for Google Closure.
  • prettyPrint - boolean to toggle pretty formatting of JS output.
  • endCallback - called when compilation of all resources completes.
  • externPaths - array of absolute paths to js files or directories with js files to use for extern declarations.

More info

For the latest Google Closure Compiler and Template files visit:

  • npm i -g google-closure-compiler
  • https://github.com/google/closure-templates/releases

Latest soy compiler can be found at https://repo1.maven.org/maven2/com/google/template/soy/ which also has the latest soyutils js file.

See http://code.google.com/closure/compiler/docs/api-ref.html for more details on the compiler options.

See http://lesscss.org/ for more details about LESS.

License

Apache v2. See the LICENSE file.