Skip to content

Commit 518dde5

Browse files
committed
chore(build): added wiredep to wire Bower dependencies to source code
1 parent 23fe2c4 commit 518dde5

5 files changed

Lines changed: 44 additions & 17 deletions

File tree

.bowerrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
22
"directory": "vendor",
3-
"json": "bower.json"
3+
"scripts": {
4+
"postinstall": "gulp wiredep"
5+
}
46
}

config.json

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,12 @@
1919
"tests" : "src/+(app|common)/**/*.spec.js"
2020
},
2121

22-
"vendor_files": {
23-
"js": [
24-
"vendor/angular/angular.js",
25-
"vendor/angular-ui-router/release/angular-ui-router.js",
26-
"vendor/angular-bootstrap/ui-bootstrap-tpls.js"
27-
],
28-
"css": [
29-
],
30-
"assets": [
31-
"vendor/bootstrap-sass-official/assets/fonts/**/*"
22+
"bower": {
23+
"json": "./bower.json",
24+
"directory": "./vendor/",
25+
"exclude": [
26+
"jquery",
27+
"vendor/bootstrap-sass-official/assets/javascripts"
3228
]
3329
},
3430

gulpfile.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var gulp = require('gulp'),
44
map = require('map-stream'),
55
del = require('del'),
66
minimist = require('minimist'),
7+
wiredep = require('wiredep').stream,
78
plugins = require('gulp-load-plugins')(),
89
server = require('tiny-lr')(),
910
config = require('./config.json'),
@@ -110,7 +111,20 @@ gulp.task('vendor:assets', function () {
110111
return gulp.src(config.vendor_files.assets, { base: '.' })
111112
.pipe(gulp.dest(config.build + '/assets'));
112113
});
114+
// Wire Bower dependencies to source code
115+
// ======================================
116+
117+
gulp.task('wiredep', function () {
118+
var options = {
119+
bowerJson: require(config.bower.json),
120+
directory: config.bower.directory,
121+
exclude: config.bower.exclude
122+
};
113123

124+
return gulp.src(config.paths.html)
125+
.pipe(wiredep(options))
126+
.pipe(gulp.dest(config.build));
127+
});
114128

115129

116130
// Prepare JavaScript
@@ -221,8 +235,8 @@ gulp.task('assets', ['assets:img', 'vendor:assets'], function () {
221235
// Inject CSS & JS to index.html source
222236
var fnInject = function (path) {
223237
var inject = {
224-
css : (config.vendor_files.css).concat(config.build + '/assets/*.css'),
225-
js : (config.vendor_files.js).concat(config.build + '/+(app|common)/**/*.module.js').concat(config.build + '/+(app|common)/**/*.js')
238+
css : [config.build + '/assets/*.css'],
239+
js : [config.build + '/+(app|common)/**/*.module.js', config.build + '/+(app|common)/**/*.js']
226240
};
227241

228242
var sources = gulp.src(inject.css.concat(inject.js), { read: false });

server.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module.exports = function (lr, options) {
1818
// app.use(require('connect-modrewrite')(['!\\.\\w+$ /index.html']));
1919
app.use(require('connect-livereload')({ port: LIVERELOAD_PORT }));
2020
app.use(serveStatic(EXPRESS_ROOT));
21+
app.use('/vendor', serveStatic('vendor'));
2122
app.use('/', serveIndex(EXPRESS_ROOT));
2223

2324
var server = http.createServer(app);

src/index.html

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,15 @@
44
<meta charset="UTF-8">
55
<title ng-bind="pageTitle"></title>
66

7-
<!-- build:css --><!-- inject:css -->
8-
<!-- endinject --><!-- endbuild -->
7+
<!-- build:css assets/vendor.min.css -->
8+
<!-- bower:css -->
9+
<!-- endbower -->
10+
<!-- endbuild -->
11+
12+
<!-- build:css assets/app.min.css -->
13+
<!-- inject:css -->
14+
<!-- endinject -->
15+
<!-- endbuild -->
916

1017
</head>
1118
<body ng-cloak>
@@ -38,8 +45,15 @@
3845
</div>
3946
</div>
4047

41-
<!-- build:js --><!-- inject:js -->
42-
<!-- endinject --><!-- endbuild -->
48+
<!-- build:js assets/vendor.min.js -->
49+
<!-- bower:js -->
50+
<!-- endbower -->
51+
<!-- endbuild -->
52+
53+
<!-- build:js assets/app.min.js -->
54+
<!-- inject:js -->
55+
<!-- endinject -->
56+
<!-- endbuild -->
4357

4458
</body>
4559
</html>

0 commit comments

Comments
 (0)