Skip to content

Instantly share code, notes, and snippets.

@kulturpessimist
Last active August 29, 2015 14:00
Show Gist options
  • Save kulturpessimist/930e4173a73e83258ea3 to your computer and use it in GitHub Desktop.
Save kulturpessimist/930e4173a73e83258ea3 to your computer and use it in GitHub Desktop.
Example grunt couchapp workflow
.
├── build
│   ├── css
│   ├── i18n
│   ├── img
│   ├── js
│   └── partials
├── couchapp
├── grunt
├── migration
├── node_modules
├── [...]
└── src
├── css
├── i18n
├── img
├── js
│   ├── angular
│   │   └── i18n
│   ├── app
│   └── vendor
└── partials
1661 directories
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json')
});
grunt.loadTasks('grunt');
// Tasks
grunt.registerTask('default', ['build']);
grunt.registerTask('build', ['clean', 'concat', 'copy', 'htmlmin', 'autoprefixer', 'cssmin', 'uglify']);
grunt.registerTask('couch', ['build', 'couchapp']);
};
module.exports = function(grunt) {
grunt.config('clean', {
build: {
src: ['build/']
}
});
grunt.config('concat', {
dist: {
src: [
'frontend/js/vendor/*.js',
'frontend/js/angular/i18n/*.js',
'frontend/js/angular/i18n/angular.js',
'frontend/js/angular/i18n/angular-resource.js'
],
dest: 'frontend/js/libs.grunt.js',
}
});
grunt.config('copy', {
dist: {
files: [
{ expand: true, cwd: 'src/i18n/', src: ['*'], dest: 'build/i18n/'},
{ expand: true, cwd: 'src/img/', src: ['*.{ico,jpg,gif,png,svg}'], dest: 'build/img/'}
]
}
});
grunt.config('autoprefixer', {
options: {
browsers: ['> 1%']
},
dist: {
src: 'src/css/**/*.css',
dest: 'src/css/style.grunt.css'
}
});
grunt.config('cssmin', {
dist: {
files: {
'build/css/style.min.css': 'src/css/style.grunt.css'
}
}
});
grunt.config('htmlmin', {
dist: {
options: {
removeComments: true,
removeRedundantAttributes: true,
collapseWhitespace: true
},
files: [
{ 'build/index.html': 'src/index.html'},
{ expand: true, cwd: 'src/partials', src: ['*.html'], dest: 'build/partials' }
]
}
});
grunt.config('uglify', {
options: {
banner: '/*! \n<%= pkg.name %> \nVersion <%= pkg.version %>\n <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
src: 'frontend/js/libs.grunt.js',
dest:'build/js/libs.min.js'
}
});
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-autoprefixer');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-htmlmin');
grunt.loadNpmTasks('grunt-contrib-uglify');
};
module.exports = function(grunt) {
var pkg = grunt.file.readJSON('package.json');
var couchdb = {
iris: {
db: 'http://admin:******@natureoffice.iriscouch.com/grunt-couchapp',
app: 'couchapp/app.js',
options: {
okay_if_missing: true
}
}
}
grunt.config('mkcouchdb', couchdb);
grunt.config('rmcouchdb', couchdb);
grunt.config('couchapp', couchdb);
grunt.loadNpmTasks('grunt-couchapp');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment