New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

anvil.js

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

anvil.js

Static javascript / coffeescript build utility

  • 0.2.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by133.33%
Maintainers
1
Weekly downloads
 
Created
Source

Anvil

I wanted a way to build a single javascript module from several source files. Jake/Rake/Make aren't really doing enough for me. Everything else I found that came close was also trying to enforce how that output got used (Ender, Require, etc.).

If it's still not clear, I really built anvil for me, but you can use it too :)

Anvil; Dumb but Helpful

Anvil just wants to be your friend. If you don't have a build.json file, Anvil will compile something based on conventions. See the convention section below...

More than likely you will want a build.json file for more control. Should you be too lazy to hammer one out, just type:

anvil template

and it will create a build.json for you. Even better, you can choose to name the template like so:

anvil template coffee.json

Quick Start

Look at the demo directory. It's very simple. If you've installed anvil from npm, all you have to do is type:

cd demo
anvil

and watch how anvil builds the demo project.

If you've pulled the repository down, then try this: cd demo ../bin/anvil

If all's well, you should get some console output and the build directory should have three output files.

Combine source files

Anvil allows you to combine source files by using a commented command Javascript //import("dependency.js");

Coffeescript ###import "dependency.js" ###

When you use Anvil to compile your project, it will traverse all the files in your source directory and combine them so that your top level files are what get output. Warning Currently, Anvil is not clever enough to detect circular import statements and it will break the world if you do this.

By Convention

Without a build file, Anvil will make assumptions. Here's the list:

  • All your source will be in ./src
  • Your output will go to ./lib
  • You want .coffee files compiled to .js
  • Your final files will get run through lint
  • Your final files will then be uglified as *.min.js
  • Your final files will then be gzipped as *.min.gz.js

There isn't a wrapper by convention.

The Build File

{
    "source": "src",
    "output": "build",
    "lint": {},
    "uglify": {},
    "gzip": {},
    "extensions": { "uglify": "min", "gzip": "gz" },
    "wrap": {
        "prefix": "(function(context) {",
        "suffix": "})(this);"
    }
}

source is where Anvil expects all your code. Don't get fancy or Anvil can't help you. output is where Anvil will write all the build output and temp files. This should NOT be the same as source. lint specifies that you want your output files run through JSLint before Uglify and Gzip occur. uglify specifies that you want your output uglified. (happens before gzip) gzip specifies that you want your output gzipped.

wrap prefix prepends the following string to your output files. suffix appends the following string to your output files.

There's also another option called justCoffee that will cause anvil to maintain all output in coffeescript instead of compiling it to js.

Multiple Targets

Instead of making your build.json files messy with multiple targets, you can have multiple .json files for each target and name them according to the platform. You then specify the target as a command line argument.

Example

You have two build files. The default build.json and a coffee.json. These are actually included with anvil (after all, it's self-compiling) and you can look at the difference between output generated by each.

build.json

{
    "source": "source",
    "output": "build",
    "lint": {}
}

coffee.json

{
    "source": "source",
    "output": "build",
    "justCoffee": {}
}

To target the coffee build just type:

anvil coffee

To Do

  • Add continuous build behavior
  • Provide advanced uglify configuration options
  • Provide advanced JSLint configuration options
  • Add test integration options

Keywords

FAQs

Package last updated on 15 Sep 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc