Adam Niedzielski

Solve business problems with high quality code

Using Lineman.js with AngularJS

| Comments

I’ve recently started playing with AngularJS. Coming from the Rails world I expected a structure enforced by the framework, good default configuration and separation into development, test and production environments.

It seems that the way to start a new project suggested by the creators of AngularJS is to clone angular-seed project. While this seed project worked for me during development and testing, I was a bit lost when it came to deploying to production.

The README is quite vague here and the same can be said about the comment in index.html

Should I change this one line each time I make a deployment, then copy the files to my server and finally undo the change? Next thing – there is nothing said about minification in the README. As a fresh AngularJS developer I was quite disappointed that I wasn’t able to have my app up and running quickly.

Lineman.js enters the stage

And there I stumbled upon Lineman.js. At first I thought – “yet another tool sprung in the complex world of JavaScript”. But then I decided to give it a try.

Lineman.js provides a good structure for your client-side application and is opinionated about how you should run your commands. This means that Lineman.js makes a couple of decisions for me, which I won’t be able to make as a developer learning AngularJS.

Lineman.js takes care about development and testing stages, but does not forget about pushing code to production. It knows that you want your code to be concatenated and minified in production.

You can start with lineman-angular-template, which gives you some nice defaults such as:

1
2
3
4
angular.module('app').
  controller('ArtistController', function ($scope, $routeParams) {
    ...
  });

instead of:

1
2
3
4
angular.module('app').
  controller('ArtistController', ['$scope', '$routeParams', function ($scope, $routeParams) {
    ...
  }]);

and your code will still be minified correctly

Conclusion

Lineman.js is very easy to learn – start from its homepage. You can check my AngularJS toy project – classky which I built with Lineman.js. Everything worked out of the box and I cannot see any negative sides of using this tool. Recommended!


Did you enjoy this post? Sign up to my newsletter to get the next bits!

AngularJS, Lineman.js, javascript, tools

« Black-box testing My take on services in Rails »

Comments