Closed edtalmadge closed 8 years ago
I was able to resolve the issue by updating the default pattern. Added a couple instances of "!? ":
var pattern = options.pattern || new RegExp("([\\t ]*\\/\\*\!? ?" + options.start_comment + " ?\\*\\/)[\\s\\S]*?(\\/\\*\!? ?" + options.end_comment + " ?\\*\\/[\\t ]*\\n?)", "g");
I added a pull request:
I tried and I was able to achieve what you want using:
start_comment: "! start-removeMe", end_comment: "! end-removeMe"
If the problem is different just provide me an example how to reproduce your case. @edtalmadge
Thanks @massick, here is an example.
To summarize: I have a gulp task which first compiles the sass file style.scss, then runs gulp-strip-code. The gulp-strip-code comment markers are in backgrounds.scss, which is imported by style.scss.
Gulp Task:
gulp.task("sass", function () {
gulp.src(['sass/style.scss'])
.pipe(sass({ outputStyle: 'expanded' }))
.pipe(stripCode({
start_comment: "start-stripFromNR",
end_comment: "end-stripFromNR"
}))
.pipe(gulp.dest('sass/css/'));
}
style.scss (processed by the above task):
@import "../sass/mixins/_backgrounds.scss";
backgrounds.scss (imported in the above style.scss):
/*! start-stripFromNR */
.helloWorld { color: red; }
/*! end-stripFromNR */
yes, but what about using
start_comment: "! start-stripFromNR",
end_comment: "! end-stripFromNR"
if you want to strip out the code in between?
You are right, that works. I was able to update my code and verify.
Cool, I will close the PR then!
For example, the following example code is not removed as expected:
But, if I were to remove the exclamation points, it is removed just fine.
I need the exclamation points because my goal is to run gulp-strip-code on my files after gulp-sass is done with them. And, gulp-sass only preserves comments that have an exclamation point.