Skip to content

Commit

Permalink
Merge branch 'master' of github.com:devongovett/rust-css-transformer
Browse files Browse the repository at this point in the history
  • Loading branch information
devongovett committed Apr 8, 2023
2 parents 406a6b7 + 78ab48f commit 1583dd1
Show file tree
Hide file tree
Showing 10 changed files with 653 additions and 386 deletions.
986 changes: 607 additions & 379 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -47,7 +47,7 @@ substitute_variables = ["visitor", "into_owned"]
[dependencies]
serde = { version = "1.0.123", features = ["derive"], optional = true }
cssparser = "0.29.1"
parcel_selectors = { version = "0.25.1", path = "./selectors" }
parcel_selectors = { version = "0.25.2", path = "./selectors" }
itertools = "0.10.1"
smallvec = { version = "1.7.0", features = ["union"] }
bitflags = "1.3.2"
Expand Down
2 changes: 1 addition & 1 deletion c/cbindgen.toml
@@ -1,7 +1,7 @@
language = "C"

[parse]
parse_deps = true
parse_deps = false
include = ["lightningcss"]

[export.rename]
Expand Down
1 change: 1 addition & 0 deletions c/lightningcss.h
Expand Up @@ -124,6 +124,7 @@ typedef struct ToCssOptions {
bool source_map;
const char *input_source_map;
uintptr_t input_source_map_len;
const char *project_root;
struct Targets targets;
bool analyze_dependencies;
struct PseudoClasses pseudo_classes;
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -6,6 +6,7 @@
"main": "node/index.js",
"types": "node/index.d.ts",
"exports": {
"types": "./node/index.d.ts",
"import": "./node/index.mjs",
"require": "./node/index.js"
},
Expand Down
10 changes: 5 additions & 5 deletions selectors/Cargo.toml
@@ -1,10 +1,10 @@
[package]
name = "parcel_selectors"
version = "0.25.1"
version = "0.25.2"
authors = ["The Servo Project Developers"]
documentation = "https://docs.rs/selectors/"
documentation = "https://docs.rs/parcel_selectors/"
description = "CSS Selectors matching for Rust - forked for lightningcss"
repository = "https://github.com/servo/servo"
repository = "https://github.com/parcel-bundler/lightningcss"
readme = "README.md"
keywords = ["css", "selectors"]
license = "MPL-2.0"
Expand All @@ -23,11 +23,11 @@ bitflags = "1.0"
cssparser = "0.29"
fxhash = "0.2"
log = "0.4"
phf = "0.8"
phf = "0.10"
precomputed-hash = "0.1"
smallvec = "1.0"
serde = { version = "1.0.123", features = ["derive"], optional = true }
schemars = { version = "0.8.11", features = ["smallvec"], optional = true }

[build-dependencies]
phf_codegen = "0.8"
phf_codegen = "0.10"
4 changes: 4 additions & 0 deletions src/main.rs
Expand Up @@ -217,6 +217,10 @@ pub fn main() -> Result<(), std::io::Error> {
}
}

let output_path = Path::new(output_file);
if let Some(p) = output_path.parent() {
fs::create_dir_all(p)?
};
fs::write(output_file, code.as_bytes())?;

if let Some(css_modules) = cli_args.css_modules {
Expand Down
23 changes: 23 additions & 0 deletions tests/cli_integration_tests.rs
Expand Up @@ -5,6 +5,7 @@ use indoc::indoc;
use lightningcss::css_modules::CssModuleExport;
use predicates::prelude::*;
use std::collections::HashMap;
use std::fs;
use std::process::Command;

fn test_file() -> Result<assert_fs::NamedTempFile, FixtureError> {
Expand Down Expand Up @@ -182,6 +183,28 @@ fn output_file_option() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}

#[test]
fn output_file_option_create_missing_directories() -> Result<(), Box<dyn std::error::Error>> {
let infile = test_file()?;
let outdir = assert_fs::TempDir::new()?;
let outfile = outdir.child("out.css");
outdir.close()?;
let mut cmd = Command::cargo_bin("lightningcss")?;
cmd.arg(infile.path());
cmd.arg("--output-file").arg(outfile.path());
cmd.assert().success();
outfile.assert(predicate::str::contains(indoc! {
r#"
.foo {
border: none;
}
"#
}));
fs::remove_dir_all(outfile.parent().unwrap())?;

Ok(())
}

#[test]
fn minify_option() -> Result<(), Box<dyn std::error::Error>> {
let infile = test_file()?;
Expand Down
5 changes: 5 additions & 0 deletions website/docs.css
Expand Up @@ -64,6 +64,11 @@ header .title {
text-decoration: none;
}

header .title::selection {
-webkit-text-stroke-color: #fffddd;
background-color: var(--gold-text);
}

h1, h2, h3 {
font-family: urbane-rounded, ui-rounded;
font-weight: 600;
Expand Down
5 changes: 5 additions & 0 deletions website/index.html
Expand Up @@ -263,6 +263,11 @@ <h3>Browser grade</h3>
letter-spacing: -0.02em;
}

header h1::selection {
-webkit-text-stroke-color: #fffddd;
background-color: var(--gold-text);
}

header h2 {
font-family: urbane-rounded;
color: lch(65% 85 35);
Expand Down

0 comments on commit 1583dd1

Please sign in to comment.