Skip to content

Commit b246f74

Browse files
committed
feat(angular2-app): allow to easily add vendor files
to be able to easily add vendor files in generated projects: var Angular2App = require('angular-cli/lib/broccoli/angular2-app'); module.exports = function(defaults) { var app = new Angular2App(defaults, { vendorFiles: ['material-design-lite/material.css'] }); return app.toTree(); }
1 parent e78adef commit b246f74

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

addon/ng2/blueprints/ng2/files/ember-cli-build.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
var Angular2App = require('angular-cli/lib/broccoli/angular2-app');
44

55
module.exports = function(defaults) {
6-
var app = new Angular2App(defaults);
6+
var app = new Angular2App(defaults, {
7+
vendorFiles: []
8+
});
79
return app.toTree();
810
}

lib/broccoli/angular2-app.js

+21-15
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,26 @@ module.exports = Angular2App;
1111
function Angular2App(defaults, options) {
1212
this._initProject();
1313
this._notifyAddonIncluded();
14+
this.options = options;
1415
}
1516

16-
Angular2App.prototype.toTree = function () {
17+
Angular2App.prototype.toTree = function() {
1718
var sourceTree = 'src';
19+
var vendorNpmFiles = [
20+
'angular2/bundles/angular2-polyfills.js',
21+
'angular2/bundles/angular2.dev.js',
22+
'angular2/bundles/http.dev.js',
23+
'angular2/bundles/router.dev.js',
24+
'angular2/bundles/upgrade.dev.js',
25+
'es6-shim/es6-shim.js',
26+
'rxjs/bundles/Rx.js',
27+
'systemjs/dist/system.src.js',
28+
'systemjs/dist/system-polyfills.js'
29+
];
30+
31+
if (this.options.vendorNpmFiles) {
32+
vendorNpmFiles = vendorNpmFiles.concat(this.options.vendorNpmFiles);
33+
}
1834

1935
var tsConfigCompilerOptions = JSON.parse(fs.readFileSync('src/tsconfig.json', 'utf-8')).compilerOptions;
2036
var tsTree = compileWithTypescript(sourceTree, tsConfigCompilerOptions);
@@ -33,19 +49,9 @@ Angular2App.prototype.toTree = function () {
3349
exclude: ['**/*.ts', '**/*.js', 'src/tsconfig.json'],
3450
allowEmpty: true
3551
});
36-
37-
var vendorJsTree = new Funnel('node_modules', {
38-
files: [
39-
'angular2/bundles/angular2-polyfills.js',
40-
'angular2/bundles/angular2.dev.js',
41-
'angular2/bundles/http.dev.js',
42-
'angular2/bundles/router.dev.js',
43-
'angular2/bundles/upgrade.dev.js',
44-
'es6-shim/es6-shim.js',
45-
'rxjs/bundles/Rx.js',
46-
'systemjs/dist/system.src.js',
47-
'systemjs/dist/system-polyfills.js'
48-
],
52+
53+
var vendorNpmTree = new Funnel('node_modules', {
54+
files: vendorNpmFiles,
4955
destDir: 'vendor'
5056
});
5157

@@ -73,7 +79,7 @@ Angular2App.prototype.toTree = function () {
7379
tsTree,
7480
jsTree,
7581
this.index(),
76-
vendorJsTree,
82+
vendorNpmTree,
7783
thirdPartyJs
7884
], { overwrite: true });
7985
};

0 commit comments

Comments
 (0)