config.jsonOptions
{Object}
Provides options that can be applied to JSON loading. The JSON extension has the following options:
Object
Properties
-
transform
{function(load, data)}
Optional
A function that allows you to transform the JSON object that will be used as the module value.
steal.config({
jsonOptions: {
transform: function(load, data) {
// Delete secret data
delete data._secret;
return data;
}
}
});
-
load
{Object}
The load object for this module. Use this if you need to know the module's name or other metadata to determine how to transform it.
-
data
{Object}
The raw JSON data parsed by JSON.parse
.
Use
jsonOptions is useful when your app (or one of your dependencies is importing a JSON file that isn't meant to be exposed in production. For example many packages do:
Which will be imported by Steal. However the package.json contains metadata include paths on your filesystem that you likely don't want exposed by a web-server.
Typically code only needs their version for a few properties, such as the version. Using the transform function we can remove all others:
When compiled every other property will be excluded from the build.