Search code examples
cssnode.jsnpmgulpcompass

Disable/Enable css comment line with gulp


Is there a way to disable a specific css comment at a certain line with Gulp, and enable it after a build task ?

For example, I would like to disable my @import 'compass/reset'; which is at the first line of my css file, and enable it after the build task.

Thanks in advance !


Solution

  • Yes there is. You need this Gulp plugin. It's called gulp-strip-code , you simply need to add two comment lines above and below it, just like the CSS/JS unifiers do, like so:

    NOTE: I am writing this down, as I presume that you have the needed knowledge about Gulp.

    /* test-code */
    @import 'compass/reset';
    /* end-test-code */
    

    It is fairly easy to implement. Just follow the instructions on the plugin page.

    Navigate to your main project dir with the node folder and install it like so:

    npm install gulp-strip-code --save-dev

    Then, create a task for it and pipe the custom comments that You would like to use like so:

    .pipe(stripCode({
      start_comment: "start-test-block",
      end_comment: "end-test-block"
    }))