Skip to content
Maxime LUCE edited this page Mar 8, 2015 · 3 revisions

When using grunt-html-build, you can generate a HTML page which remove some dev parts.

index.html

<html>
	<head>
		...
	</head>
	<body>
		<div> ... </div>
		<p> ... </p>
		<!-- build:remove -->
		<p class="debug-only"></p>
		<input type="text" id="test" />
		<!-- /build -->
		<!-- build:remove dev,test -->
		<p class="prod-only"></p>
		<!-- /build -->
	</body>
</html>

Gruntfile.js

grunt.initConfig({
    htmlbuild: {
        dist: {
            src: 'index.html',
            dest: 'dist/'
        }
    }
});

Result

<html>
	<head>
		...
	</head>
	<body>
		<div> ... </div>
		<p> ... </p>
		<p class="prod-only"></p>
	</body>
</html>

Per target

Note that .prod-only is part is kept because we configured remove task to remove this part only during dev or test target.

Clone this wiki locally