Skip to content

Instantly share code, notes, and snippets.

@scmx
Forked from tessalt/gruntfile.js
Last active November 29, 2022 13:28
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scmx/7238449 to your computer and use it in GitHub Desktop.
Save scmx/7238449 to your computer and use it in GitHub Desktop.
Update 0.4.1 gruntfile with additions to support both jade and html. Add separate diff with changes needed after using generator-angular 0.5.1 Create a new app with `yo angular` and then apply this diff
$ cat app/index.html | pbcopy
pbpaste > app/index.jade
wget https://gist.github.com/scmx/7238449/raw/cc9720e52947c74f03c0b9675fead8b42c0216ef/generator-angular-jade.diff
git apply generator-angular-jade.diff
diff --git a/Gruntfile.js b/Gruntfile.js
index e06d479..d6d45f7 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -34,18 +34,36 @@ module.exports = function (grunt) {
files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
tasks: ['copy:styles', 'autoprefixer']
},
+ jade: {
+ files: ['<%= yeoman.app %>/{,*/}*.jade'],
+ tasks: ['jade']
+ },
livereload: {
options: {
livereload: '<%= connect.options.livereload %>'
},
files: [
- '<%= yeoman.app %>/{,*/}*.html',
+ '{<%= yeoman.app %>,.tmp}/{,*/}*.html',
'.tmp/styles/{,*/}*.css',
'{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js',
'<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
]
}
},
+ jade: {
+ dist: {
+ options: {
+ pretty: true
+ },
+ files: [{
+ expand: true,
+ cwd: '<%= yeoman.app %>',
+ dest: '.tmp',
+ src: '{,*/}*.jade',
+ ext: '.html'
+ }]
+ }
+ },
autoprefixer: {
options: ['last 1 version'],
dist: {
@@ -174,7 +192,7 @@ module.exports = function (grunt) {
}
},
useminPrepare: {
- html: '<%= yeoman.app %>/index.html',
+ html: '.tmp/index.html',
options: {
dest: '<%= yeoman.dist %>'
}
@@ -235,7 +253,12 @@ module.exports = function (grunt) {
files: [{
expand: true,
cwd: '<%= yeoman.app %>',
- src: ['*.html', 'views/*.html'],
+ src: ['*.html', 'views/{,*/}*.html'],
+ dest: '<%= yeoman.dist %>'
+ }, {
+ expand: true,
+ cwd: '.tmp',
+ src: ['*.html', 'views/{,*/}*.html'],
dest: '<%= yeoman.dist %>'
}]
}
@@ -273,6 +296,7 @@ module.exports = function (grunt) {
},
concurrent: {
server: [
+ 'jade',
'coffee:dist',
'compass:server',
'copy:styles'
@@ -347,6 +371,7 @@ module.exports = function (grunt) {
grunt.registerTask('build', [
'clean:dist',
+ 'jade',
'useminPrepare',
'concurrent:dist',
'autoprefixer',
diff --git a/app/index.jade b/app/index.jade
index adf21b7..79e816a 100644
--- a/app/index.jade
+++ b/app/index.jade
@@ -1,10 +1,10 @@
!!! 5
//if lt IE 7
- html.no-js.lt-ie9.lt-ie8.lt-ie7
+ html.no-js.lt-ie9.lt-ie8.lt-ie7
//if IE 7
- html.no-js.lt-ie9.lt-ie8
+ html.no-js.lt-ie9.lt-ie8
//if IE 8
- html.no-js.lt-ie9
+ html.no-js.lt-ie9
// [if gt IE 8] <!
html.no-js
// <![endif]
@@ -41,7 +41,7 @@ html.no-js
ga('send', 'pageview');
script(src='bower_components/jquery/jquery.js')
script(src='bower_components/angular/angular.js')
- // build:js scripts/plugins.js
+ // build:js(app) scripts/plugins.js
script(src='bower_components/bootstrap-sass/js/bootstrap-affix.js')
script(src='bower_components/bootstrap-sass/js/bootstrap-alert.js')
script(src='bower_components/bootstrap-sass/js/bootstrap-dropdown.js')
@@ -56,7 +56,7 @@ html.no-js
script(src='bower_components/bootstrap-sass/js/bootstrap-collapse.js')
script(src='bower_components/bootstrap-sass/js/bootstrap-tab.js')
// endbuild
- // build:js scripts/modules.js
+ // build:js(app) scripts/modules.js
script(src='bower_components/angular-resource/angular-resource.js')
script(src='bower_components/angular-cookies/angular-cookies.js')
script(src='bower_components/angular-sanitize/angular-sanitize.js')
diff --git a/package.json b/package.json
index 3d26068..0e2aa05 100644
--- a/package.json
+++ b/package.json
@@ -16,6 +16,7 @@
"grunt-contrib-htmlmin": "~0.1.3",
"grunt-contrib-imagemin": "~0.2.0",
"grunt-contrib-watch": "~0.5.2",
+ "grunt-contrib-jade": "~0.8.0",
"grunt-autoprefixer": "~0.2.0",
"grunt-usemin": "~0.1.11",
"grunt-svgmin": "~0.2.0",
diff --git a/Gruntfile.js b/Gruntfile.js
index 4fdfdce..333a203 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -30,18 +30,36 @@ module.exports = function (grunt) {
files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
tasks: ['copy:styles', 'autoprefixer']
},
+ jade: {
+ files: ['<%= yeoman.app %>/{,*/}*.jade'],
+ tasks: ['jade']
+ },
livereload: {
options: {
livereload: '<%= connect.options.livereload %>'
},
files: [
- '<%= yeoman.app %>/{,*/}*.html',
+ '{<%= yeoman.app %>,.tmp}/{,*/}*.html',
'.tmp/styles/{,*/}*.css',
'{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js',
'<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
]
}
},
+ jade: {
+ dist: {
+ options: {
+ pretty: true
+ },
+ files: [{
+ expand: true,
+ cwd: '<%= yeoman.app %>',
+ dest: '.tmp',
+ src: '{,*/}*.jade',
+ ext: '.html'
+ }]
+ }
+ },
autoprefixer: {
options: ['last 1 version'],
dist: {
@@ -149,7 +167,7 @@ module.exports = function (grunt) {
}
},
useminPrepare: {
- html: '<%= yeoman.app %>/index.html',
+ html: '.tmp/index.html',
options: {
dest: '<%= yeoman.dist %>'
}
@@ -210,7 +228,12 @@ module.exports = function (grunt) {
files: [{
expand: true,
cwd: '<%= yeoman.app %>',
- src: ['*.html', 'views/*.html'],
+ src: ['*.html', 'views/{,*/}*.html'],
+ dest: '<%= yeoman.dist %>'
+ }, {
+ expand: true,
+ cwd: '.tmp',
+ src: ['*.html', 'views/{,*/}*.html'],
dest: '<%= yeoman.dist %>'
}]
}
@@ -248,6 +271,7 @@ module.exports = function (grunt) {
},
concurrent: {
server: [
+ 'jade',
'coffee:dist',
'copy:styles'
],
@@ -319,6 +343,7 @@ module.exports = function (grunt) {
grunt.registerTask('build', [
'clean:dist',
+ 'jade',
'useminPrepare',
'concurrent:dist',
'autoprefixer',
diff --git a/app/index.jade b/app/index.jade
index 1d2982c..bed82b9 100644
--- a/app/index.jade
+++ b/app/index.jade
@@ -40,7 +40,7 @@ html.no-js
ga('create', 'UA-XXXXX-X');
ga('send', 'pageview');
script(src='bower_components/angular/angular.js')
- // build:js scripts/modules.js
+ // build:js(app) scripts/modules.js
script(src='bower_components/angular-resource/angular-resource.js')
script(src='bower_components/angular-cookies/angular-cookies.js')
script(src='bower_components/angular-sanitize/angular-sanitize.js')
diff --git a/package.json b/package.json
index b637d53..03a6989 100644
--- a/package.json
+++ b/package.json
@@ -16,6 +16,7 @@
"grunt-contrib-htmlmin": "~0.1.3",
"grunt-contrib-imagemin": "~0.2.0",
"grunt-contrib-watch": "~0.5.2",
+ "grunt-contrib-jade": "~0.8.0",
"grunt-autoprefixer": "~0.2.0",
"grunt-usemin": "~0.1.11",
"grunt-svgmin": "~0.2.0",
// Generated on 2013-08-28 using generator-webapp 0.4.1
'use strict';
var LIVERELOAD_PORT = 35729;
var lrSnippet = require('connect-livereload')({port: LIVERELOAD_PORT});
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'
module.exports = function (grunt) {
// show elapsed time at the end
require('time-grunt')(grunt);
// load all grunt tasks
require('load-grunt-tasks')(grunt);
// configurable paths
var yeomanConfig = {
app: 'app',
dist: 'dist'
};
grunt.initConfig({
yeoman: yeomanConfig,
watch: {
coffee: {
files: ['<%= yeoman.app %>/scripts/{,*/}*.coffee'],
tasks: ['coffee:dist']
},
coffeeTest: {
files: ['test/spec/{,*/}*.coffee'],
tasks: ['coffee:test']
},
compass: {
files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
tasks: ['compass:server', 'autoprefixer']
},
styles: {
files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
tasks: ['copy:styles', 'autoprefixer']
},
jade: {
files: ['<%= yeoman.app %>/{,*/}*.jade'],
tasks: ['jade']
},
livereload: {
options: {
livereload: LIVERELOAD_PORT
},
files: [
'{<%= yeoman.app %>,.tmp}/{,*/}*.html',
'.tmp/styles/{,*/}*.css',
'{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js',
'<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
]
}
},
connect: {
options: {
port: 9000,
// change this to '0.0.0.0' to access the server from outside
hostname: 'localhost'
},
livereload: {
options: {
middleware: function (connect) {
return [
lrSnippet,
mountFolder(connect, '.tmp'),
mountFolder(connect, yeomanConfig.app)
];
}
}
},
test: {
options: {
middleware: function (connect) {
return [
mountFolder(connect, '.tmp'),
mountFolder(connect, 'test'),
mountFolder(connect, yeomanConfig.app)
];
}
}
},
dist: {
options: {
middleware: function (connect) {
return [
mountFolder(connect, yeomanConfig.dist)
];
}
}
}
},
open: {
server: {
path: 'http://localhost:<%= connect.options.port %>'
}
},
jade: {
dist: {
options: {
pretty: true
},
files: [{
expand: true,
cwd: '<%= yeoman.app %>',
dest: '.tmp',
src: '{,*/}*.jade',
ext: '.html'
}]
}
},
clean: {
dist: {
files: [{
dot: true,
src: [
'.tmp',
'<%= yeoman.dist %>/*',
'!<%= yeoman.dist %>/.git*'
]
}]
},
server: '.tmp'
},
jshint: {
options: {
jshintrc: '.jshintrc'
},
all: [
'Gruntfile.js',
'<%= yeoman.app %>/scripts/{,*/}*.js',
'!<%= yeoman.app %>/scripts/vendor/*',
'test/spec/{,*/}*.js'
]
},
mocha: {
all: {
options: {
run: true,
urls: ['http://localhost:<%= connect.options.port %>/index.html']
}
}
},
coffee: {
dist: {
files: [{
expand: true,
cwd: '<%= yeoman.app %>/scripts',
src: '{,*/}*.coffee',
dest: '.tmp/scripts',
ext: '.js'
}]
},
test: {
files: [{
expand: true,
cwd: 'test/spec',
src: '{,*/}*.coffee',
dest: '.tmp/spec',
ext: '.js'
}]
}
},
compass: {
options: {
sassDir: '<%= yeoman.app %>/styles',
cssDir: '.tmp/styles',
generatedImagesDir: '.tmp/images/generated',
imagesDir: '<%= yeoman.app %>/images',
javascriptsDir: '<%= yeoman.app %>/scripts',
fontsDir: '<%= yeoman.app %>/styles/fonts',
importPath: '<%= yeoman.app %>/bower_components',
httpImagesPath: '/images',
httpGeneratedImagesPath: '/images/generated',
httpFontsPath: '/styles/fonts',
relativeAssets: false
},
dist: {
options: {
generatedImagesDir: '<%= yeoman.dist %>/images/generated'
}
},
server: {
options: {
debugInfo: true
}
}
},
autoprefixer: {
options: {
browsers: ['last 1 version']
},
dist: {
files: [{
expand: true,
cwd: '.tmp/styles/',
src: '{,*/}*.css',
dest: '.tmp/styles/'
}]
}
},
// not used since Uglify task does concat,
// but still available if needed
/*concat: {
dist: {}
},*/
'bower-install': {
app: {
html: '<%= yeoman.app %>/index.html',
ignorePath: '<%= yeoman.app %>/'
}
},
// not enabled since usemin task does concat and uglify
// check index.html to edit your build targets
// enable this task if you prefer defining your build targets here
/*uglify: {
dist: {}
},*/
rev: {
dist: {
files: {
src: [
'<%= yeoman.dist %>/scripts/{,*/}*.js',
'<%= yeoman.dist %>/styles/{,*/}*.css',
'<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp}',
'<%= yeoman.dist %>/styles/fonts/{,*/}*.*'
]
}
}
},
useminPrepare: {
options: {
dest: '<%= yeoman.dist %>'
},
html: '.tmp/index.html'
},
usemin: {
options: {
dirs: ['<%= yeoman.dist %>']
},
html: ['<%= yeoman.dist %>/{,*/}*.html'],
css: ['<%= yeoman.dist %>/styles/{,*/}*.css']
},
imagemin: {
dist: {
files: [{
expand: true,
cwd: '<%= yeoman.app %>/images',
src: '{,*/}*.{png,jpg,jpeg}',
dest: '<%= yeoman.dist %>/images'
}]
}
},
svgmin: {
dist: {
files: [{
expand: true,
cwd: '<%= yeoman.app %>/images',
src: '{,*/}*.svg',
dest: '<%= yeoman.dist %>/images'
}]
}
},
htmlmin: {
dist: {
files: [{
expand: true,
cwd: '.tmp',
src: '*.html',
dest: '<%= yeoman.dist %>'
}]
}
},
// Put files not handled in other tasks here
copy: {
dist: {
files: [{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>',
dest: '<%= yeoman.dist %>',
src: [
'*.{ico,png,txt}',
'.htaccess',
'images/{,*/}*.{webp,gif}',
'styles/fonts/{,*/}*.*'
]
}]
},
styles: {
expand: true,
dot: true,
cwd: '<%= yeoman.app %>/styles',
dest: '.tmp/styles/',
src: '{,*/}*.css'
}
},
concurrent: {
server: [
'compass',
'jade',
'coffee:dist',
'copy:styles'
],
test: [
'coffee',
'copy:styles'
],
dist: [
'coffee',
'compass',
'copy:styles',
'imagemin',
'svgmin',
'htmlmin'
]
}
});
grunt.registerTask('server', function (target) {
if (target === 'dist') {
return grunt.task.run(['build', 'open', 'connect:dist:keepalive']);
}
grunt.task.run([
'clean:server',
'concurrent:server',
'autoprefixer',
'connect:livereload',
'open',
'watch'
]);
});
grunt.registerTask('test', [
'clean:server',
'concurrent:test',
'autoprefixer',
'connect:test',
'mocha'
]);
grunt.registerTask('build', [
'clean:dist',
'jade',
'useminPrepare',
'concurrent:dist',
'autoprefixer',
'concat',
'cssmin',
'uglify',
'copy:dist',
'rev',
'usemin'
]);
grunt.registerTask('default', [
'jshint',
'test',
'build'
]);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment