• Stars
    star
    199
  • Rank 196,105 (Top 4 %)
  • Language
    JavaScript
  • License
    Microsoft Public ...
  • Created over 13 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

SassAndCoffee adds support in ASP.NET MVC to (you guessed it!) Sass/SCSS and CoffeeScript

SassAndCoffee

This library adds simple, drop-in support for Sass/SCSS as well as CoffeeScript. Javascript and CoffeeScript files can also be minified and combined via UglifyJS.

How to use:

First, add the desired package reference(s) via NuGet. You probably want SassAndCoffee.AspNet.

CoffeeScript

  • Add a .coffee file to your project. For purposes of this example we'll use ~/Scripts/main.coffee
  • Reference that file in your page as if it were compiled JavaScript: <script src="/Scripts/main.js" />
  • By default the CoffeeScript compiler will wrap your scripts. If for some reason you want bare mode, request it: <script src="/Scripts/main.bare.js" />
  • Note: If a file exists named ~/Scripts/main.js, it will be served instead of ~/Scripts/main.coffee. SassAndCoffee always preferentially serves existing files on disk.

JavaScript Minification

  • You can request minification of any JavaScript file by adding .min to the filename before .js. <script src="/Scripts/main.min.js" /> will serve the minified version of <script src="/Scripts/main.js" />
  • This of course works with CoffeeScript files (as described above), including bare support: <script src="/Scripts/main.bare.min.js" />

JavaScript Combination

  • Create a .combine file. We'll use ~/Scripts/home.combine for this example.
  • Fill it with the absolute, relative, and App-relative paths of the scripts you want included:
# This line is a comment
# Include our minified CoffeeScript file with an absolute path
~/Scripts/main.min.js
# Include another file in ~/Scripts
header.js
# Include a file in a subfolder of ~/Scripts
subfolder/file.js
  • Reference that file in your page as if it were compiled JavaScript: <script src="/Scripts/home.js" />
  • Note: For now, we recommend that you minify the included files, rather than the combined file. Uglify can choke on exceedingly large inputs.
  • Note: If a file exists named ~/Scripts/home.js, it will be served instead of ~/Scripts/home.combine. SassAndCoffee always preferentially serves existing files on disk.

Sass/SCSS

  • Add a .scss or .sass file to your project. We'll use ~/Content/site.scss for this example.
  • Reference that file in your page as if it were compiled CSS: <link href="/Content/site.css" type="text/css" />
  • CSS combination can be achieved with @import ""; directives
  • Minification works just like with JavaScript (but only for Sass/SCSS files). Just add .min to the filename before .css. <link rel="stylesheet" href="/Content/site.min.css" type="text/css" /> will serve the minified version of <link rel="stylesheet" href="/Content/site.css" type="text/css" />
  • Note: If a file exists named ~/Content/site.css, it will be served instead of ~/Scripts/site.scss. SassAndCoffee always preferentially serves existing files on disk.

What about performance?

SassAndCoffee offloads caching and compression to ASP.Net and IIS. To modify the default cache settings, alter the SassAndCoffeeCacheSettings cache profile in web.config. To enable compression, install IIS's compression features.

SassAndCoffee watches your source files for changes and invalidates the cache when appropriate.

How does it work?

SassAndCoffee embeds the original compilers in the DLL (Sass 3.2.0 and CoffeeScript 1.1.3 as of this writing) and uses IronRuby and JScript respectively to execute the compilers against your source.

SassAndCoffee will even use IE9's faster Chakra JScript engine if it's detected. Since JScript doesn't ship with Windows Server Core editions, it will not work on those systems.

Why is this better than [SOMEOTHERPROJECT]?

  • No external processes are executed
  • You don't have to install Ruby or node.js
  • It's in NuGet so you don't have to fiddle with web.config
  • Files are cached and are rebuilt as-needed.

Problems

If you run into bugs / have feature suggestions / have questions, please either send me an Email at [email protected], or file a Github bug.

Thanks to:

Several folks helped me out with some of the integration details of this project

  • if it weren't for them, I would still be stuck in the mud right now:
  • David Padbury for helping me out with the CoffeeScript compiler
  • Levi Broderick for giving me a few hints as to how to rig up the HttpModule
  • Jimmy Schementi for telling me the proper way to redirect 'requires' to an embedded resource
  • Thanks to Hampton Catlin and Jeremy Ashkenas for creating such awesome languages in the first place
  • The folks on the #chromium IRC channel for helping me with a tricky V8 issue
  • Steven Robbins for the ton of work put in to refactor the code to work with NancyFx and other non-ASP.NET frameworks

Packages

SassAndCoffee.AspNet

Adds Sass/SCSS, CoffeeScript, and UglifyJS support to ASP.Net projects. Works with WebForms and MVC

SassAndCoffee.JavaScript

The SassAndCoffee JavaScript compilers for CoffeeScript and UglifyJS. Great for integration into your own packages. Just include it as a dependency.

SassAndCoffee.Ruby

The SassAndCoffee Ruby compilers for Sass/SCSS. Great for integration into your own packages. Just include it as a dependency.

SassAndCoffee.Core

Shared components used by SassAndCoffee.JavaScript and SassAndCoffee.Ruby. Unlikely you'll want to reference this directly.

SassAndCoffee

This legacy package is now an alias for SassAndCoffee.AspNet.

More Repositories

1

ModernHttpClient

HttpClient implementations that use platform-native HTTP clients for 🚀
C#
661
star
2

starter-mobile

Starter project for Mobile projects at GitHub
C#
156
star
3

spawn-rx

Observable and Promise versions of child_process.spawn
TypeScript
136
star
4

xvfb-maybe

Run an executable under xvfb-run, but only when needed
JavaScript
133
star
5

grunt-build-atom-shell

Grunt task to build Electron and rebuild node modules
CoffeeScript
122
star
6

LinqToAwait

A Task-based LINQ designed to work with async/await
C#
113
star
7

node-system-idle-time

Node module to get system-idle-time, fork with Linux support
C++
101
star
8

XamarinEvolve2014

App Repo for "Building Apps the GitHub Way"
C#
91
star
9

SaveAllTheTime

SaveAllTheTime makes it so you never commit files to Git without saving ever again
C#
73
star
10

AkavacheExplorer

A utility to poke around in Akavache caches
C#
68
star
11

squirrel-flutter

Build installers for your Flutter applications with Squirrel
Dart
57
star
12

PerMonitorDpi

Enable Windows 8.1+ Per-Monitor DPI support for Desktop WPF Apps
C#
51
star
13

ssh-agent-relay

Make your WSL installation use your Windows SSH Agent
Shell
37
star
14

atom-twitch

Atom plugin for Live Coding
JavaScript
34
star
15

RunscopeEverything

An Xposed module that will rewrite all web requests on Android and point them to Runscope
Java
27
star
16

midi-mixer-wavexlr

A Wave Link plugin for MIDI Mixer
JavaScript
23
star
17

typechat-cli

A command-line wrapper around TypeChat - invoke OpenAI or Ollama with a specific JS schema
TypeScript
21
star
18

commands

Commands - a React Hooks library for writing async code
TypeScript
21
star
19

ReactiveUI.Sample

Sample 3.0â„¢
C#
20
star
20

starter-sample

ReactiveUI + Akavache + Splat Sample
C#
20
star
21

BigNerdIOS-MonoDevelop

Big Nerd Ranch's iOS book, but in MonoDevelop
C#
18
star
22

XamarinRxDemo

Java
14
star
23

xamarin-dep-rebuild

A hack to rebuild all of the libraries we use in Xamarin apps
Shell
13
star
24

sirene

Dart
13
star
25

CaliburnMicro

My hacks on top of Caliburn Micro
C#
12
star
26

OneTrueCSharpStyle

The One True C# Style
12
star
27

electron-vue-sample

Vue 2.0 single-file components + electron-compile
JavaScript
12
star
28

libcef

Mirror of CEF3
C++
12
star
29

reactiveui

This Repo Is Dead, you want https://github.com/reactiveui/reactiveui
C#
11
star
30

OkHttp-Xamarin

Xamarin bindings for squareup/okhttp
C#
11
star
31

aluqard

GraphQL + Flutter Hooks
Dart
11
star
32

when

Observe JavaScript objects with RxJS
TypeScript
10
star
33

trickline

A Fucking Fast Slack Data Model
TypeScript
10
star
34

peasant

The simplest CI server that could possibly work
C#
9
star
35

PhotoDispatcher

A site to send Eye-Fi photos to multiple sites via an iPhone site
Ruby
8
star
36

Shotclock

A NuGet package to encourage you to create small commits
C#
8
star
37

rxjs-serial-subscription

RxJS 5.x version of SerialSubscription
JavaScript
8
star
38

commands-compose

Commands - a Jetpack Compose library for writing async events
Kotlin
7
star
39

RxUIInterfaceToVM

Hack code to use Roslyn + Mustache to codegen ReactiveUI ViewModels
C#
7
star
40

github-emoji-switcher

A Chrome Extension that switches old-and-busted Apple Emojis into new and ✨ Shiny ✨ Hangouts emoji! 🚀
JavaScript
7
star
41

vcachefs

A media caching filesystem written using FUSE
C
6
star
42

blogstrap

A GitHub Pages-based starter template for your blog
JavaScript
6
star
43

Shroom

Java
6
star
44

Tasks

A Ruby library to parse Taskpaper and other todo list formats
Ruby
5
star
45

component-store-nupkg-builder

A set of scripts to build Xamarin Component Store shim packages
Ruby
5
star
46

vue-pwa-typescript

Vue 2.5's PWA template using the new Babel 7.x TypeScript preset
JavaScript
5
star
47

AFNetworking-Xamarin

Xamarin AFNetworking binding, based on thefactory/AFNetworking-Sharp
C#
5
star
48

GistForVS

A VSIX extension that adds the ability to create Gists from Visual Studio
C#
5
star
49

InstallQueuer

A Windows app to queue up several MSIs to install in the background
C#
5
star
50

rdio-play-here

List all of your running machines and make Rdio play on any of them
JavaScript
5
star
51

zapped

A small utility to add XServer's Zap to Windows and OS X
C
4
star
52

chromeapp-materialdesign

Demo for Chrome App + Material Design + AngularJS
JavaScript
4
star
53

RxUIBlog

All of the RxUI blog posts and some tooling to create a PDF / ePub version
4
star
54

GameShare

A website to organize small groups to borrow video games
Ruby
4
star
55

yikes

An automatic way to convert videos and put them on your iPod
C
4
star
56

camploco

Camp Lakota Merit Badge Site
JavaScript
4
star
57

windows-terminal-theme-sync

VS Code extension to sync color themes with Windows Terminal
TypeScript
3
star
58

mongodbfs

A FUSE filesystem over MongoDB's GridFS
C
3
star
59

ModernCommonLogging

Common.Logging for .NET 4.0 / SL4 / WP7
3
star
60

pinguine-wsl

Utility to improve WSL
3
star
61

ReactiveXaml

This project has been renamed to ReactiveUI - check it out below!
3
star
62

poolsuite-androidtv

The literal bare minimum to get poolsuite onto my heckin TV
Dart
3
star
63

desktop-analytics

Common Analytics and Reporting
C#
3
star
64

foo

3
star
65

slack-all-langs

Sample code to post a message in every language to Slack
JavaScript
3
star
66

Estelle

A command-line music reorganization app
C++
3
star
67

groupme-ios-sdk

A GroupMe client library for iOS devices
Objective-C
3
star
68

lithium

A Reactive API for Home Assistant
TypeScript
2
star
69

xpaulbettsx.github.com

Ruby
2
star
70

electron-sample

Sample app using the CLI
CoffeeScript
2
star
71

play-wp8

Dummy project, ignore this
C#
2
star
72

NSync

NSync
2
star
73

gformat

A GNOME disk formatting utility I wrote a billion years ago
C
2
star
74

password2

password with offline support
JavaScript
2
star
75

channels-web

Web client for Channels
TypeScript
2
star
76

ReactiveUI_5.99.3-beta-WP8

Repro repo for issue with the ReactiveUI 5.99.3-beta NuGet package
C#
2
star
77

RxUI_BindingFailure

Demonstrates the combobox selected item binding failure
C#
2
star
78

Istoria

My life in code
Ruby
2
star
79

HerokuClickonceTest

This is not a thing.
Ruby
2
star
80

Malcolm

An application that helps you be more productive
C#
2
star
81

LeeMe.Mobile

So you can be about that life.
C#
2
star
82

saveallthetime-atom

SaveAllTheTime makes it so you never commit files to Git without saving ever again
CoffeeScript
1
star
83

OBSKeyboardMute

Mute your clackety keyboard in OBS
C#
1
star
84

glibc-legal-notice

An npm package whose license metadata describes your linking to glibc
1
star
85

ShroomServer

1
star
86

marie

keep your house clutter-free!
TypeScript
1
star
87

esdoc-plugin-async-to-sync

Auto-documents your sync methods using the async versions
JavaScript
1
star
88

when-flutter

Dart
1
star
89

flutter-actions

Action Hooks, a Flutter Hook for building asynchronous commands
Dart
1
star
90

debug-electron

It's debug, but electron-friendly
JavaScript
1
star
91

timeout-cli

GNU timeout but cross-platform also with missing features
JavaScript
1
star
92

toilet-paper-cheater

it does.
TypeScript
1
star
93

slime

An Atom plugin to communicate with your inferiors (processes)
CoffeeScript
1
star
94

symlink-test

Ignore me
1
star