dciccale / grunt-processhtml

Process html files at build time to modify them depending on the release environment
MIT License
407 stars 30 forks source link

comment/uncomment code blocks #103

Closed vlrprbttst closed 8 years ago

vlrprbttst commented 8 years ago

I use processhtml to embed critical css. The problem I have is I only want it to be inlined on my build process, but have it removed while on dev.

my gruntfile.js looks like this:

        processhtml: {
            dev: {
                files: [{
                    expand: true,
                    cwd: '<%= source %>/',
                    src: ['**/*.html'],
                    dest: '<%= dev %>/',
                    ext: '.html'
                }, ],
            },
            build: {
                files: [{
                    expand: true,
                    cwd: '<%= dev %>/',
                    src: ['**/*.html'],
                    dest: '<%= site %>/',
                    ext: '.html'
                }, ],
            }
        },

from my source folder i have

<!-- build:css:build inline -->
<link rel="stylesheet" href="../_dev/critical-css/index.css">
<!-- /build -->

and this works, but I would need an intermediate state where in DEV i have that line commented, and in DIST to be uncommented and inlined.

I doubt I was clear but I hope you get it. you can find the full thing here to better understand: https://github.com/vlrprbttst/BoxTent

Is there a way to achieve this? maybe via a comment/uncomment option or a template? thanks! :)

dciccale commented 8 years ago

run grunt processhtml:dev to only target dev

dciccale commented 8 years ago

so, i checked your repo.

add another block in your html

<!-- build:css:dev -->
<link rel="stylesheet" href="../_dev/critical-css/index.css">
<!-- /build -->

with dev target, and without inline