Skip to content

Commit

Permalink
Add the ability to disable the inclusion of certain assets.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomtom5152 committed Aug 29, 2016
1 parent 7880458 commit fef3907
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 18 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ For more details component usage and asset generation, see the [ember-cli-dynami

The schema variable can be in string or object form, but needs to be a valid json-schema alpaca form definition. See the [alpacajs website](http://alpacajs.org) for more information about building valid schemas.

## Excluding Assets
By default ember-cli-dynamic-forms imports bootstrap and alpaca assets to the broccoli tree. If you wish to disable this behaviour and use your own assets, simply specify it in your ember-cli-build.js.

```js
var app = new EmberApp({
'ember-cli-dynamic-forms': {
includeAssets: false, // disables the includion of all assets
includeBootstrapAssets: false // disables just the inclusion of bootstrap assets whilst leaving the rest inplace
}
});
```

## Development

### Setup
Expand Down
48 changes: 30 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,42 @@ module.exports = {
name: 'ember-cli-dynamic-forms',
included: function (app) {
this._super.included(app);

app.options = app.options || {}; // ensure options is actually set to prevent undefined errors
var options = app.options['ember-cli-dynamic-forms'] || {}; // ensure we have an options object at the very least

// opt out early if we don't want any assets
if('includeAssets' in options && !options.includeAssets) {
return;
}

app.import(app.bowerDirectory + '/handlebars/handlebars.js');
app.import(app.bowerDirectory + '/bootstrap/dist/js/bootstrap.js');
app.import(app.bowerDirectory + '/bootstrap/dist/css/bootstrap.css');
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff', {
destDir: 'fonts'
});
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.eot', {
destDir: 'fonts'
});
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.svg', {
destDir: 'fonts'
});
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf', {
destDir: 'fonts'
});
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2', {
destDir: 'fonts'
});

// include bootstrap assets unless explicitly told otherwise
if(!('includeBootstrapAssets' in options) || options.includeBootstrapAssets) {
app.import(app.bowerDirectory + '/bootstrap/dist/js/bootstrap.js');
app.import(app.bowerDirectory + '/bootstrap/dist/css/bootstrap.css');
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff', {
destDir: 'fonts'
});
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.eot', {
destDir: 'fonts'
});
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.svg', {
destDir: 'fonts'
});
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf', {
destDir: 'fonts'
});
app.import('bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2', {
destDir: 'fonts'
});
}

app.import(app.bowerDirectory + '/alpaca/dist/alpaca/bootstrap/alpaca.js');
app.import(app.bowerDirectory + '/alpaca/dist/alpaca/bootstrap/alpaca.css');
app.import(app.bowerDirectory + '/lodash/lodash.js');


},
isDevelopingAddon: function () {
return false;
Expand Down

0 comments on commit fef3907

Please sign in to comment.