Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<h1>Hello World!</h1>
.tmp/
dev/
- index.html
includes/
- content.html
Gruntfile.js
package.json
'use strict';
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-processhtml');
grunt.initConfig({
connect: {
dev: {
options: {
port: 9000,
base: '.tmp',
keepalive: true
}
}
},
processhtml: {
dev: {
options: {
includeBase: 'includes'
},
files: [{
expand: true,
cwd: 'dev',
src: ['{,*/}*.html'],
dest: '.tmp'
}]
}
}
});
grunt.registerTask('default', function() {
grunt.task.run([
'processhtml:dev',
'connect:dev',
])
})
}
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Grunt Includes Test</title>
</head>
<body>
<!-- build:include content.html -->
This content will be replaced by the include
<!-- /build -->
</body>
</html>
{
"name": "grunt-includes-example",
"version": "0.1.0",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-connect": "^0.7.1",
"grunt-processhtml": "^0.3.3",
"load-grunt-tasks": "^0.4.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.