2014-01-10 01:03:28 +04:00
|
|
|
module.exports = function (grunt) {
|
|
|
|
|
|
|
|
var appConfig = grunt.file.readJSON('package.json');
|
|
|
|
|
|
|
|
// Load grunt tasks automatically
|
|
|
|
// see: https://github.com/sindresorhus/load-grunt-tasks
|
|
|
|
require('load-grunt-tasks')(grunt);
|
|
|
|
|
|
|
|
// Time how long tasks take. Can help when optimizing build times
|
|
|
|
// see: https://npmjs.org/package/time-grunt
|
|
|
|
require('time-grunt')(grunt);
|
|
|
|
|
|
|
|
var pathsConfig = function (appName) {
|
|
|
|
this.app = appName || appConfig.name;
|
|
|
|
|
|
|
|
return {
|
|
|
|
app: this.app,
|
|
|
|
templates: this.app + '/templates',
|
|
|
|
css: this.app + '/static/css',
|
2014-01-10 12:09:46 +04:00
|
|
|
sass: this.app + '/static/sass',
|
2014-01-10 01:03:28 +04:00
|
|
|
fonts: this.app + '/static/fonts',
|
|
|
|
images: this.app + '/static/images',
|
|
|
|
js: this.app + '/static/js',
|
|
|
|
manageScript: this.app + '/manage.py'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
grunt.initConfig({
|
|
|
|
|
|
|
|
paths: pathsConfig(),
|
|
|
|
pkg: appConfig,
|
|
|
|
|
|
|
|
// see: https://github.com/gruntjs/grunt-contrib-watch
|
|
|
|
watch: {
|
|
|
|
gruntfile: {
|
|
|
|
files: ['Gruntfile.js']
|
|
|
|
},
|
|
|
|
compass: {
|
2014-01-10 12:09:46 +04:00
|
|
|
files: ['<%= paths.sass %>/**/*.{scss,sass}'],
|
2014-01-10 01:03:28 +04:00
|
|
|
tasks: ['compass:server']
|
|
|
|
},
|
|
|
|
livereload: {
|
|
|
|
files: [
|
|
|
|
'<%= paths.js %>/**/*.js',
|
2014-01-10 12:09:46 +04:00
|
|
|
'<%= paths.sass %>/**/*.{scss,sass}',
|
2014-01-10 01:03:28 +04:00
|
|
|
'<%= paths.app %>/**/*.html'
|
|
|
|
],
|
|
|
|
options: {
|
|
|
|
spawn: false,
|
|
|
|
livereload: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// see: https://github.com/gruntjs/grunt-contrib-compass
|
|
|
|
compass: {
|
|
|
|
options: {
|
2014-01-10 12:09:46 +04:00
|
|
|
sassDir: '<%= paths.sass %>',
|
2014-01-10 01:03:28 +04:00
|
|
|
cssDir: '<%= paths.css %>',
|
|
|
|
fontsDir: '<%= paths.fonts %>',
|
|
|
|
imagesDir: '<%= paths.images %>',
|
|
|
|
relativeAssets: false,
|
|
|
|
assetCacheBuster: false,
|
|
|
|
raw: 'Sass::Script::Number.precision = 10\n'
|
|
|
|
},
|
|
|
|
dist: {
|
|
|
|
options: {
|
|
|
|
environment: 'production'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
server: {
|
|
|
|
options: {
|
|
|
|
// debugInfo: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// see: https://npmjs.org/package/grunt-bg-shell
|
|
|
|
bgShell: {
|
|
|
|
_defaults: {
|
|
|
|
bg: true
|
|
|
|
},
|
|
|
|
runDjango: {
|
|
|
|
cmd: 'python <%= paths.manageScript %> runserver'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
grunt.registerTask('serve', [
|
|
|
|
'bgShell:runDjango',
|
|
|
|
'watch'
|
|
|
|
]);
|
|
|
|
|
|
|
|
grunt.registerTask('build', [
|
|
|
|
'compass:dist'
|
|
|
|
]);
|
|
|
|
|
|
|
|
grunt.registerTask('default', [
|
|
|
|
'build'
|
|
|
|
]);
|
|
|
|
};
|