|
| 1 | +--- |
| 2 | +layout: docs |
| 3 | +title: Cassette |
| 4 | +--- |
| 5 | + |
| 6 | +[Cassette](http://getcassette.net/) is an asset bundling library for ASP.NET. |
| 7 | +You can learn more on [its website at getcassette.net](http://getcassette.net/). |
| 8 | +ReactJS.NET supports the use of Cassette to compile JSX into JavaScript and |
| 9 | +minify it along with all your other JavaScript. To use Cassette with JSX, |
| 10 | +install the [React.Cassette](https://www.nuget.org/packages/Cassette.React/) |
| 11 | +NuGet package and modify your `CassetteConfiguration.cs` file to include `.jsx` |
| 12 | +files in your bundle. |
| 13 | + |
| 14 | +```csharp |
| 15 | +bundles.Add<ScriptBundle>("main.js", |
| 16 | + // Add your JSX files here |
| 17 | + "~/Content/HelloWorld.react.jsx", |
| 18 | + "~/Content/AnythingElse.react.jsx", |
| 19 | + // You can include regular JavaScript files in the bundle too |
| 20 | + "~/Content/ajax.js" |
| 21 | +); |
| 22 | +``` |
| 23 | + |
| 24 | +This will add all three files into a `main.js` bundle that you can reference and |
| 25 | +render from your view using Cassette: |
| 26 | + |
| 27 | +```html{2-3,13} |
| 28 | +@{ |
| 29 | + Bundles.Reference("main.css"); |
| 30 | + Bundles.Reference("main.js"); |
| 31 | +} |
| 32 | +<!DOCTYPE html> |
| 33 | +<html> |
| 34 | +<head> |
| 35 | + @Bundles.RenderStylesheets() |
| 36 | +</head> |
| 37 | +<body> |
| 38 | + ... |
| 39 | + <script src="http://fb.me/react-0.10.0.min.js"></script> |
| 40 | + @Bundles.RenderScripts() |
| 41 | +</body> |
| 42 | +``` |
| 43 | + |
| 44 | +See the [React.Samples.Cassette](https://github.com/reactjs/React.NET/tree/master/src/React.Sample.Cassette) |
| 45 | +project for an example. |
| 46 | + |
| 47 | +Precompilation |
| 48 | +============== |
| 49 | + |
| 50 | +**New in ReactJS.NET 0.2.0** |
| 51 | + |
| 52 | +Cassette supports using an MSBuild task to minify and combine your assets before |
| 53 | +deployment. This makes the start time of your application a lot quicker, and is |
| 54 | +also required to use JSX files on Linux via Mono (as the JSX transformer does |
| 55 | +not currently support Mono). |
| 56 | + |
| 57 | +Refer to the Cassette |
| 58 | +[compile-time bundle generation using MSBuild](http://getcassette.net/documentation/v2/msbuild) |
| 59 | +documentation for more information. |
0 commit comments