Last active
December 16, 2015 15:29
-
-
Save simshanith/5456607 to your computer and use it in GitHub Desktop.
Building dev & production HTML with Jade & Grunt.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html><!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7"><![endif]--><!--[if IE 7]><html class="no-js lt-ie9 lt-ie8"><![endif]--><!--[if IE 8]><html class="no-js lt-ie9"><![endif]--><!--[if gt IE 8]><!--> | |
<html class="no-js" lang="en"><!--<![endif]--> | |
<head> | |
<meta charset="utf-8"> | |
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"> | |
<title>Example Jade Template</title> | |
<script src="/_assets/js/modernizr-2.6.2.min.js"></script> | |
</head> | |
<body> | |
<h1>Example Jade Template</h1> | |
<p>All my dev stuffz.</p> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html><!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7"><![endif]--><!--[if IE 7]><html class="no-js lt-ie9 lt-ie8"><![endif]--><!--[if IE 8]><html class="no-js lt-ie9"><![endif]--><!--[if gt IE 8]><!--> | |
<html class="no-js" lang="en"><!--<![endif]--> | |
<head> | |
<meta charset="utf-8"> | |
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"> | |
<title>Example Jade Template</title> | |
<script src="/_assets/js/modernizr-2.6.2.min.js"></script> | |
</head> | |
<body> | |
<h1>Example Jade Template</h1> | |
<p>All my prod stuffz.</p> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!!! 5 | |
//if lt IE 7 | |
<html class="no-js lt-ie9 lt-ie8 lt-ie7"> | |
//if IE 7 | |
<html class="no-js lt-ie9 lt-ie8"> | |
//if IE 8 | |
<html class="no-js lt-ie9"> | |
//[if gt IE 8]><! | |
html.no-js(lang="en") | |
| <!--<![endif]--> | |
head | |
meta(charset='utf-8') | |
meta(http-equiv='X-UA-Compatible', content='IE=edge,chrome=1') | |
title Example Jade Template | |
body | |
h1 Example Jade Template | |
- if (build==="dev") | |
p All my dev stuffz. | |
- else | |
p All my prod stuffz. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) { | |
grunt.loadNpmTasks('grunt-contrib-jade'); | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
meta: { | |
name: 'Example Grunt+Jade Build Configuration', | |
banner: '/* <%= meta.name %> - v<%= pkg.version %> - <%= template.today("m/d/yyyy") %> */' | |
}, | |
jade: { | |
options: { | |
pretty: true, | |
data: { | |
build: '<%= grunt.task.current.target || "default" %>' | |
} | |
}, | |
prod: { | |
files: [{ | |
expand: true, // Enable dynamic expansion. | |
cwd: 'htdocs/', // Src matches are relative to this path. | |
src: ['**/*.jade'], // Actual pattern(s) to match. | |
dest: 'htdocs/', // Destination path prefix. | |
ext: '.html', // Dest filepaths will have this extension. | |
}] | |
}, | |
dev: { | |
files: [{ | |
expand: true, // Enable dynamic expansion. | |
cwd: 'htdocs/', // Src matches are relative to this path. | |
src: ['**/*.jade'], // Actual pattern(s) to match. | |
dest: 'htdocs/', // Destination path prefix. | |
ext: '.dev.html', // Dest filepaths will have this extension. | |
}] | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment