Skip to content

Commit

Permalink
Document resource appSetting overriding
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarmil committed Nov 17, 2015
1 parent 435578b commit db6217e
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion docs/Resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,37 @@ do()
The resource dependency graphs are constructed for every WebSharper-processed
assembly and are serialized to binary. They are stored within the
assembly itself. At runtime all the graphs of all the referenced assemblies
are deserialized and merged into a single graph.
are deserialized and merged into a single graph.

## Overriding Resource URLs

External resources implemented using `BaseResource` can have their URL
overridden on a per-application basis. For example, you can force your
application to use a different version of JQuery than the one used by default
by WebSharper.

This configuration is done in the application configuration file. As a
standard, for self-hosted projects, that file is called `App.config`, and for
other types of web projects, it's `Web.config`. WebSharper recognizes both, and
uses `Web.config` if both are present.

To override a given resource URL, simply add an appSetting whose key is the
fully qualified name of the resource, and whose value is the URL you want to
use. For example, to tell WebSharper to use a local copy of JQuery located at
the root of your application, you can add the following to your application
configuration file:

```xml
<configuration>
<appSettings>
<add key="WebSharper.JQuery.Resources.JQuery" value="/jquery.js" />
<!-- ... -->
```

Note that the fully qualified name is in IL format. This means that nested
types and types located inside F# modules are separated by `+` instead of `.`.

If you are a library author and have a resource declared by directly
implementing the `IResource` interface, you can make it configurable by using
the function `ctx.GetSetting`, which retrieves the setting with a given key
from the application configuration file.

0 comments on commit db6217e

Please sign in to comment.