Skip to content

Instantly share code, notes, and snippets.

@rmaceissoft
Created November 8, 2013 17:20
Show Gist options
  • Save rmaceissoft/7374445 to your computer and use it in GitHub Desktop.
Save rmaceissoft/7374445 to your computer and use it in GitHub Desktop.
/*global module:false*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
/* --------------------------------------- */
/* --( Variables )-- */
/* --------------------------------------- */
pkg: grunt.file.readJSON('package.json'),
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
/* --------------------------------------- */
/* --( Clean old build directory )-- */
/* --------------------------------------- */
clean: {
options: { force: true },
build: {
src: ['build']
}
},
/* --------------------------------------- */
/* --( Copy Files into Build Directory )-- */
/* --------------------------------------- */
copy: {
src: {
files: [{expand: true, cwd: 'src', src: ['**/*'], dest: 'build/'}]
}
},
/* --------------------------------------- */
/* --( Build Require.js App )-- */
/* --------------------------------------- */
requirejs: {
options: {
//
appDir: 'src/',
// Include the main configuration file.
mainConfigFile: 'src/app/common.js',
// Setting the base url to the distribution directory allows the
// Uglify minification process to correctly map paths for Source
// Maps.
baseUrl: 'app',
// output directory
dir: 'build/',
// Wrap everything in an IIFE.
wrap: true,
// Since we bootstrap with nested `require` calls this option allows
// R.js to find them.
findNestedDependencies: true,
// Include a minimal AMD implementation shim.
//name: "almond",
// modules to optimize
modules: [
{
name: 'articles'
}
]
// Output file. If you use appDir + dir this is not required
//out: 'build/source.min.js',
},
// Production Settings
release: {
options: {
// Turn on Uglification
optimize: 'uglify2',
generateSourceMaps: true,
preserveLicenseComments: false
}
},
// Development Settings
dev: {
options: {
// Turn on Uglification
optimize: 'none'
}
}
},
jst: {
compile: {
options: {
amd: true
},
files: {
"build/app/templates.js": ["build/app/templates/**/*.tpl"]
}
}
},
handlebars: {
compile: {
options: {
namespace: "JST",
amd: true,
processName: function(filePath) {
return filePath.replace('build/','');
}
},
files: {
"build/app/templates.js": ["build/app/templates/**/*.tpl"]
}
}
},
compass: {
options: {
sassDir: 'build/assets/scss',
imagesDir: 'build/assets/img',
cssDir: 'build/assets/css',
specify: 'build/assets/scss/main.scss',
require: [
'zen-grids'
],
relativeAssets: true
},
dev: {
options: {
environment: 'development'
}
},
release: {
options: {
environment: 'production'
}
}
}
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-contrib-jst');
grunt.loadNpmTasks('grunt-contrib-handlebars');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.registerTask('build:dev', ['clean:build', 'copy', 'compass:dev', 'handlebars', 'requirejs:dev']);
grunt.registerTask('build:release', ['clean:build', 'copy', 'compass:release', 'handlebars', 'requirejs:release']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment