Skip to content

Commit 85462cf

Browse files
authored
Merge pull request #14 from thedodd/13-sass_rs
Cut over to sass-rs, as it is a feature complete sass/scss solution.
2 parents f321eab + e7dce90 commit 85462cf

File tree

9 files changed

+230
-195
lines changed

9 files changed

+230
-195
lines changed

.github/workflows/ci.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: ci
2+
on: [push]
3+
4+
jobs:
5+
build:
6+
name: build
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
matrix:
10+
os: [ubuntu-latest, macos-latest, windows-latest]
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions-rs/toolchain@v1
14+
with:
15+
toolchain: stable
16+
- uses: actions-rs/cargo@v1
17+
with:
18+
command: build
19+
# verify that we can actually execute the CLI and get some output
20+
- uses: actions-rs/cargo@v1
21+
with:
22+
command: run
23+
args: -- -h

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
changelog
2+
=========
3+
4+
## Unreleased
5+
6+
## 0.1.2
7+
### changed
8+
- Swap our `grass` for `sass-rs`.
9+
- Compress SASS/SCSS output when building in `--release` mode.
10+
11+
## 0.1.1
12+
### fixed
13+
- Fix an issue with the watch system which was breaking builds on Windows.
14+
15+
## 0.1.0
16+
- Initialize release. See the [release notes on Github](https://github.com/thedodd/trunk/releases/tag/v0.1.0) for more info.

Cargo.lock

Lines changed: 171 additions & 187 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "trunk"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
edition = "2018"
55
description = "Build, bundle & ship your Rust WASM application to the web."
66
license = "MIT/Apache-2.0"
@@ -15,10 +15,10 @@ anyhow = "1.0.32"
1515
async-process = "0.1.1"
1616
async-std = { version="1.6.3", features=["attributes", "unstable"] }
1717
futures = "0.3.5"
18-
grass = "0.10.3"
1918
nipper = "0.1.8"
2019
notify = "4.0.15"
2120
open = "1.4.0"
21+
sass-rs = "0.2.2"
2222
seahash = "4.0.1"
2323
serde = { version="1", features=["derive"] }
2424
structopt = "0.3.16"

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
<h1 align="center">trunk</h1>
22
<div align="center">
3+
4+
[![Build Status](https://github.com/thedodd/trunk/workflows/ci/badge.svg?branch=master)](https://github.com/thedodd/trunk/actions)
5+
[![Crates.io](https://img.shields.io/crates/v/trunk.svg)](https://crates.io/crates/trunk)
6+
[![License](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue)](LICENSE)
7+
![Crates.io](https://img.shields.io/crates/d/trunk.svg)
8+
![Crates.io](https://img.shields.io/crates/dv/trunk.svg)
9+
310
<strong>
411
Build, bundle & ship your Rust WASM application to the web.
512
</strong>
@@ -37,7 +44,7 @@ pub fn main() {
3744
}
3845
```
3946

40-
Trunk uses a source HTML file to drive all asset building and bundling. Trunk also ships with a [built-in SASS/SCSS compiler](https://github.com/connorskees/grass), so let's get started with the following example. Copy this HTML to your cargo project's `src` dir at `src/index.html`:
47+
Trunk uses a source HTML file to drive all asset building and bundling. Trunk also ships with a [built-in SASS/SCSS compiler](https://github.com/compass-rs/sass-rs), so let's get started with the following example. Copy this HTML to your cargo project's `src` dir at `src/index.html`:
4148

4249
```html
4350
<html>
@@ -82,7 +89,7 @@ Trunk leverages Rust's powerful concurrency primitives for maximum build speeds.
8289
Trunk is still a young project, and new asset types will be added as we move forward. Keep an eye on [trunk#3](https://github.com/thedodd/trunk/issues/3) for more information on planned asset types, implementation status, and please contribute to the discussion if you think something is missing.
8390

8491
Currently supported assets:
85-
-`sass`: Trunk ships with a [built-in sass/scss compiler](https://github.com/connorskees/grass). Just link to your sass files from your source HTML, and Trunk will handle the rest. This content is hashed for cache control.
92+
-`sass`: Trunk ships with a [built-in sass/scss compiler](https://github.com/compass-rs/sass-rs). Just link to your sass files from your source HTML, and Trunk will handle the rest. This content is hashed for cache control.
8693
-`css`: Trunk will copy linked css files found in the source HTML without content modification. This content is hashed for cache control.
8794
- In the future, Trunk will resolve local `@imports`, will handle minification (see [trunk#7](https://github.com/thedodd/trunk/issues/3)), and we may even look into a pattern where any CSS found in the source tree will be bundled, which would enable a nice zero-config "component styles" pattern. See [trunk#3](https://github.com/thedodd/trunk/issues/3) for more details.
8895
-`icon`: Trunk will automatically copy referenced icons to the `dist` dir. This content is hashed for cache control.

src/build.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,16 @@ impl BuildSystem {
290290
/// Spawn a concurrent build pipeline for a SASS/SCSS asset.
291291
fn spawn_sass_pipeline(&mut self, asset: AssetFile) -> JoinHandle<Result<AssetPipelineOutput>> {
292292
let dist = self.dist.clone();
293+
let release = self.release;
293294
spawn(async move {
294295
// Compile the target SASS/SCSS file.
295296
let path_str = asset.path.to_string_lossy().to_string();
297+
let mut opts = sass_rs::Options::default();
298+
if release {
299+
opts.output_style = sass_rs::OutputStyle::Compressed;
300+
}
296301
let css = spawn_blocking(move || {
297-
match grass::from_path(&path_str, &grass::Options::default()) {
302+
match sass_rs::compile_file(&path_str, opts) {
298303
Ok(css) => Ok(css),
299304
Err(err) => {
300305
eprintln!("{}", err);

src/cmd/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub struct Build {
2121
#[structopt(short, long, default_value="dist", parse(from_os_str))]
2222
dist: PathBuf,
2323
/// The public URL from which assets are to be served.
24-
#[structopt(short, long, default_value="/", parse(from_str=parse_public_url))]
24+
#[structopt(long, default_value="/", parse(from_str=parse_public_url))]
2525
public_url: String,
2626
}
2727

src/cmd/serve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub struct Serve {
2929
#[structopt(short, long, default_value="dist", parse(from_os_str))]
3030
dist: PathBuf,
3131
/// The public URL from which assets are to be served.
32-
#[structopt(short, long, default_value="/", parse(from_str=parse_public_url))]
32+
#[structopt(long, default_value="/", parse(from_str=parse_public_url))]
3333
public_url: String,
3434
/// Additional paths to ignore.
3535
#[structopt(short, long, parse(from_os_str))]

src/cmd/watch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub struct Watch {
2121
#[structopt(short, long, default_value="dist", parse(from_os_str))]
2222
dist: PathBuf,
2323
/// The public URL from which assets are to be served.
24-
#[structopt(short, long, default_value="/", parse(from_str=parse_public_url))]
24+
#[structopt(long, default_value="/", parse(from_str=parse_public_url))]
2525
public_url: String,
2626
/// Additional paths to ignore.
2727
#[structopt(short, long, parse(from_os_str))]

0 commit comments

Comments
 (0)