Skip to content

Instantly share code, notes, and snippets.

@barmatz
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save barmatz/f61f4150e97f7fa40ff6 to your computer and use it in GitHub Desktop.

Select an option

Save barmatz/f61f4150e97f7fa40ff6 to your computer and use it in GitHub Desktop.
Gruntfile template
'use strict';
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
usebanner: {
options: {
banner: '/*!\n * <%= pkg.title || pkg.name %>\n * <%= pkg.description%>\n * Version <%= pkg.version%>\n * Compiled <%= grunt.template.today("dddd, mmmm dS, yyyy, h:MM:ss TT") %>\n */\n',
},
scripts: {
src: '{lib,dist}/**/*.js'
},
stylesheets: {
src: '{lib,dist}/**/*.css'
}
},
clean: {
tmp: '.tmp',
dist: 'dist',
lib: 'lib',
libscripts: 'lib/scripts',
libstylesheets: 'lib/stylesheets',
postcompile: {
src: 'dist/**/*',
filter: function (path) {
return grunt.file.isDir(path) && grunt.file.expand({cwd: path}, '**/*').length === 0;
}
}
},
jshint: {
options: {
jshintrc: true
},
node: ['bower.json', 'Gruntfile.js', 'package.json', 'server.js', 'webservice.js', 'tasks/**/*.js'],
src: 'src/scripts/**/*.js',
test: 'test/**/*.js'
},
concat: {
options: {
stripBanners: true,
},
src: {
dest: 'lib/scripts/application.js',
src: [].concat('.tmp/scripts/ember-templates.js', sourceFiles)
}
},
ember_handlebars: { //jshint ignore:line
options: {
namespace: 'Ember.TEMPLATES',
processName: function (filename) {
return filename.replace(/^src\/templates\/(.+).hbs$/, '$1').replace('.', '/');
}
},
src: {
files: {
'.tmp/scripts/ember-templates.js': 'src/templates/**/*.hbs'
}
}
},
uglify: {
options: {
sourceMap: true
},
lib: {
expand: true,
cwd: 'lib/scripts/',
src: ['**/*.js', '!**/*.min.js'],
dest: 'lib/scripts/',
ext: '.min.js'
}
},
cssmin: {
lib: {
expand: true,
cwd: 'lib/stylesheets/',
src: '**/*.css',
dest: 'lib/stylesheets/',
ext: '.min.css'
}
},
compass: {
src: {
options: {
sassDir: 'src/stylesheets',
cssDir: 'lib/stylesheets',
environment: 'production',
specify: [
//'src/stylesheets/reset.scss',
'src/stylesheets/style.scss'
]
}
}
},
scsslint: {
options: {
config: '.scsslintrc'
},
src: 'src/**/*.scss'
},
copy: {
assets: {
expand: true,
cwd: 'src/',
src: ['**/*', '!**/*.{js,scss,hbs}'],
dest: 'dist/',
filter: function (path) {
return !grunt.file.isDir(path) || grunt.file.expand({cwd: path}, ['**/*', '!**/*.{js,scss,hbs}']).length;
}
},
config: {
src: 'src/scripts/config.js',
dest: 'dist/scripts/config.js'
},
scripts: {
expand: true,
cwd: 'lib/scripts/',
src: '**/*.{js,map}',
dest: 'dist/scripts/'
},
stylesheets: {
expand: true,
cwd: 'lib/stylesheets/',
src: '**/*.css',
dest: 'dist/stylesheets/'
}
},
watch: {
options: {
atBegin: true,
livereload: true
},
node: {
files: ['package.json', 'Gruntfile.js', '.csslintrc', '.jshintrc'],
tasks: ['default']
},
scripts: {
files: ['**/.jshintrc', 'src/scripts/**/*.js'],
tasks: ['scripts', 'htmlcompiler']
},
tests: {
files: 'test/**/*.js',
tasks: ['jshint:test', 'htmlcompiler:test', 'qunit']
},
stylesheets: {
files: ['.compassrc', '.scsslintrc', 'src/stylesheets/**/*.scss'],
tasks: ['stylesheets', 'htmlcompiler']
},
templates: {
files: 'src/templates/**/*.hbs',
tasks: ['ember_handlebars', 'copy:scripts', 'copy:config', 'qunit']
},
assets: {
files: ['src/**.*', '!src/**/*.{js,css,hbs}'],
tasks: 'copy:assets'
},
vendor: {
files: [].concat(vendorScriptFiles, vendorStylesheetFiles),
tasks: 'htmlcompiler'
},
readme: {
files: ['.verbrc', 'docs/**/*.md'],
tasks: 'verb'
},
demo: {
files: ['src/scripts/demo.js', 'src/templates/demo.tmpl'],
tasks: 'htmlcompiler:demo'
}
},
htmlcompiler: {
options: {
vendors: [].concat('dist/scripts/config.js', vendorStylesheetFiles, vendorScriptFiles),
scripts: [
'dist/**/*.js',
'!dist/**/*.min.js',
'!dist/scripts/config.js'
],
stylesheets: ['dist/**/*.css', '!dist/**/*.min.css'],
title: '<%= pkg.title || pkg.name %>',
meta: [
{
name: 'viewport',
content: 'width=device-width, user-scalable=no'
}
],
body: '<div id="ember-app"></div>'
},
dist: {
dest: 'dist/index.html'
},
dev: {
options: {
scripts: [].concat(
'.tmp/scripts/ember-templates.js',
sourceFiles,
'http://localhost:35729/livereload.js'
)
},
dest: 'dist/index.dev.html'
},
test: {
options: {
vendors: [].concat(
'dist/scripts/config.js',
vendorScriptFiles.map(function (filename) {
switch (filename) {
case 'vendor/ember/ember.min.js':
filename = 'vendor/ember/ember.js';
break;
}
return filename;
}),
'vendor/qunit/qunit/qunit.css',
'vendor/qunit/qunit/qunit.js',
'vendor/sinon-builds/pkg/sinon-1.8.2.js',
'vendor/ember-qunit/dist/globals/main.js'
),
scripts: [
'lib/scripts/application.js',
'test/scripts/setup.js',
'test/scripts/**/*.js'
],
title: '<%= pkg.title || pkg.name %> Unit Tests',
body: grunt.file.read('test/runner.tmpl')
},
dest: 'test/runner.html'
}
}
});
grunt.loadNpmTasks('grunt-banner');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-ember-handlebars');
grunt.loadNpmTasks('grunt-html-compiler');
grunt.loadNpmTasks('grunt-scss-lint');
grunt.registerTask('default', ['jshint:node', 'clean:dist', 'scripts', 'stylesheets', 'copy', 'htmlcompiler:dist', 'htmlcompiler:dev', 'htmlcompiler:demo', 'htmlcompiler:dashboard', 'clean:postcompile', 'arke']);
grunt.registerTask('stylesheets', ['scsslint', 'clean:libstylesheets', 'compass', 'cssmin', 'copy:stylesheets', 'usebanner:stylesheets']);
grunt.registerTask('scripts', ['jshint:src', 'clean:libscripts', 'jshint:test', 'ember_handlebars', 'concat:src', 'htmlcompiler:test', 'qunit', 'uglify', 'copy:scripts', 'copy:config', 'usebanner:scripts']);
grunt.registerTask('dev', ['compass', 'cssmin', 'ember_handlebars', 'concat:src', 'uglify', 'copy', 'htmlcompiler:dist']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment