Get updates via , Github, or RSS | About

Episode 9: Auto-Compilation Aug 4, 2016

Instead of manually running elm-make yourself, use Grunt to automatically compile your Elm files anytime you save a change. Your Gruntfile (gruntfile.js) provides configuration to the grunt-elm plugin, which knows how to compile Elm, and the grunt-contrib-watch plugin, which watches for filesystem changes to the specified files.

Examples

Install
$ npm install grunt --save-dev
$ npm install grunt-elm --save-dev
$ npm install grunt-contrib-watch --save-dev
Gruntfile.js
module.exports = function(grunt) {

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    watch: {
      gruntfile: {
        files: ['*.elm'],
        tasks: ['elm']
      }
    },
    elm: {
      compile: {
        files: {
          'output.js': 'Main.elm'
        }
      }
    }
  });

  grunt.loadNpmTasks('grunt-elm');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.registerTask('default', ['elm']);

};