Skip to content
This repository was archived by the owner on Aug 30, 2021. It is now read-only.

Commit 3d199ea

Browse files
committed
feat(gulp): add wiredep gulp task
1 parent 065e01c commit 3d199ea

File tree

5 files changed

+64
-1
lines changed

5 files changed

+64
-1
lines changed

bower.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,17 @@
1414
"angular-ui-router": "~0.2.18",
1515
"bootstrap": "~3.3.6",
1616
"owasp-password-strength-test": "~1.3.0"
17+
},
18+
"overrides": {
19+
"bootstrap": {
20+
"main": [
21+
"dist/css/bootstrap.css",
22+
"dist/css/bootstrap-theme.css",
23+
"less/bootstrap.less"
24+
]
25+
},
26+
"jquery": {
27+
"main": []
28+
}
1729
}
1830
}

config/assets/default.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ module.exports = {
44
client: {
55
lib: {
66
css: [
7+
// bower:css
78
'public/lib/bootstrap/dist/css/bootstrap.css',
89
'public/lib/bootstrap/dist/css/bootstrap-theme.css'
10+
// endbower
911
],
1012
js: [
13+
// bower:js
1114
'public/lib/angular/angular.js',
1215
'public/lib/angular-resource/angular-resource.js',
1316
'public/lib/angular-animate/angular-animate.js',
@@ -16,6 +19,7 @@ module.exports = {
1619
'public/lib/angular-bootstrap/ui-bootstrap-tpls.js',
1720
'public/lib/angular-file-upload/dist/angular-file-upload.js',
1821
'public/lib/owasp-password-strength-test/owasp-password-strength-test.js'
22+
// endbower
1923
],
2024
tests: ['public/lib/angular-mocks/angular-mocks.js']
2125
},

config/assets/production.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ module.exports = {
44
client: {
55
lib: {
66
css: [
7+
// bower:css
78
'public/lib/bootstrap/dist/css/bootstrap.min.css',
89
'public/lib/bootstrap/dist/css/bootstrap-theme.min.css',
10+
// endbower
911
],
1012
js: [
13+
// bower:js
1114
'public/lib/angular/angular.min.js',
1215
'public/lib/angular-resource/angular-resource.min.js',
1316
'public/lib/angular-animate/angular-animate.min.js',
@@ -16,6 +19,7 @@ module.exports = {
1619
'public/lib/angular-bootstrap/ui-bootstrap-tpls.min.js',
1720
'public/lib/angular-file-upload/dist/angular-file-upload.min.js',
1821
'public/lib/owasp-password-strength-test/owasp-password-strength-test.js'
22+
// endbower
1923
]
2024
},
2125
css: 'public/dist/application.min.css',

gulpfile.js

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,48 @@ gulp.task('imagemin', function () {
215215
.pipe(gulp.dest('public/dist/img'));
216216
});
217217

218+
// wiredep task to default
219+
gulp.task('wiredep', function () {
220+
return gulp.src('config/assets/default.js')
221+
.pipe(plugins.wiredep({
222+
ignorePath: '../../'
223+
}))
224+
.pipe(gulp.dest('config/assets/'));
225+
});
226+
227+
// wiredep task to production
228+
gulp.task('wiredep:prod', function () {
229+
return gulp.src('config/assets/production.js')
230+
.pipe(plugins.wiredep({
231+
ignorePath: '../../',
232+
fileTypes: {
233+
js: {
234+
replace: {
235+
css: function (filePath) {
236+
var minFilePath = filePath.replace('.css', '.min.css');
237+
var fullPath = path.join(process.cwd(), minFilePath);
238+
if (!fs.existsSync(fullPath)) {
239+
return '\'' + filePath + '\',';
240+
} else {
241+
return '\'' + minFilePath + '\',';
242+
}
243+
},
244+
js: function (filePath) {
245+
var minFilePath = filePath.replace('.js', '.min.js');
246+
var fullPath = path.join(process.cwd(), minFilePath);
247+
if (!fs.existsSync(fullPath)) {
248+
return '\'' + filePath + '\',';
249+
} else {
250+
return '\'' + minFilePath + '\',';
251+
}
252+
}
253+
}
254+
}
255+
}
256+
}))
257+
.pipe(gulp.dest('config/assets/'));
258+
});
259+
218260
// Copy local development environment config example
219261
gulp.task('copyLocalEnvConfig', function () {
220262
var src = [];
@@ -339,7 +381,7 @@ gulp.task('lint', function (done) {
339381

340382
// Lint project files and minify them into two production files.
341383
gulp.task('build', function (done) {
342-
runSequence('env:dev', 'lint', ['uglify', 'cssmin'], done);
384+
runSequence('env:dev', 'wiredep:prod', 'lint', ['uglify', 'cssmin'], done);
343385
});
344386

345387
// Run the project tests

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"lodash": "~4.3.0",
4646
"lusca": "~1.3.0",
4747
"method-override": "~2.3.5",
48+
"gulp-wiredep": "~0.0.0",
4849
"mocha": "~2.4.5",
4950
"mongoose": "~4.4.3",
5051
"morgan": "~1.6.1",

0 commit comments

Comments
 (0)