diff --git a/src/rules/custom_media.rs b/src/rules/custom_media.rs index 78f56b51..2a4b377e 100644 --- a/src/rules/custom_media.rs +++ b/src/rules/custom_media.rs @@ -29,6 +29,7 @@ impl<'i> ToCss for CustomMediaRule<'i> { dest.write_str("@custom-media ")?; self.name.to_css(dest)?; dest.write_char(' ')?; - self.query.to_css(dest) + self.query.to_css(dest)?; + dest.write_char(';') } } diff --git a/tests/cli_integration_tests.rs b/tests/cli_integration_tests.rs index 1eeec239..ca365c4e 100644 --- a/tests/cli_integration_tests.rs +++ b/tests/cli_integration_tests.rs @@ -366,3 +366,22 @@ fn targets() -> Result<(), Box> { Ok(()) } + +#[test] +fn preserve_custom_media() -> Result<(), Box> { + let file = assert_fs::NamedTempFile::new("test.css")?; + file.write_str( + r#" + @custom-media --foo print; + "#, + )?; + + let mut cmd = Command::cargo_bin("parcel_css")?; + cmd.arg(file.path()); + cmd.arg("--custom-media"); + cmd.assert().success().stdout(predicate::str::contains(indoc! {r#" + @custom-media --foo print; + "#})); + + Ok(()) +} \ No newline at end of file