mrnocreativity / postcss-critical-split

A PostCSS plugin that takes existing CSS files and splits out the annotated critical styles into a seperate file.
MIT License
89 stars 6 forks source link

Important comments support bug with start/end tags #17

Closed agarzola closed 5 years ago

agarzola commented 5 years ago

Given the following CSS file:

/*! critical:start */
header {
  background-color: orange;
}

/*! critical:end */
p {
  background-color: blue;
}

/*# sourceMappingURL=test.css.map */
/* v19.04.19 +4 (c00d698d) */

I get the following critical CSS:

header {
  background-color: orange;
}

/*! critical:end */

p {
  background-color: blue;
}

/* v19.04.19 +4 (c00d698d) */

It appears that, for some reason, critical:end is not detected when using the “important comment” syntax (/*! */) preferred by Sass linters. I see support for this was added in response to #11. Was it intended to work with start/end tags?

mrnocreativity commented 5 years ago

Hey @agarzola.

Thanks for reporting this. Your observation seems correct. The end tags are not checked with important markers thus, if they are marked as important, they will not report as valid end tags.

I'll hope to have some time soon to fix this. It's been a while since I worked on it.

agarzola commented 5 years ago

Thanks for the reply, @mrnocreativity. I took a look at 1e2da93 (as I saw it references #11 in the commit message) and tried to identify an obvious source of the issue. Unfortunately, my lack of familiarity with your code is getting in the way of that. I need to move on to other tasks, so I’m using regular (/* */) comments and telling our Sass linter to ignore them for now. If I get another chance to look at this and there are no updates or PRs referencing this issue, I’ll give it another shot.

Thanks again!