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

Commit

Permalink
feat(gulp): add wiredep gulp task
Browse files Browse the repository at this point in the history
  • Loading branch information
itelo committed Mar 10, 2016
1 parent 065e01c commit 3d199ea
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 1 deletion.
12 changes: 12 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,17 @@
"angular-ui-router": "~0.2.18",
"bootstrap": "~3.3.6",
"owasp-password-strength-test": "~1.3.0"
},
"overrides": {
"bootstrap": {
"main": [
"dist/css/bootstrap.css",
"dist/css/bootstrap-theme.css",
"less/bootstrap.less"
]
},
"jquery": {
"main": []
}
}
}
4 changes: 4 additions & 0 deletions config/assets/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ module.exports = {
client: {
lib: {
css: [
// bower:css
'public/lib/bootstrap/dist/css/bootstrap.css',
'public/lib/bootstrap/dist/css/bootstrap-theme.css'
// endbower
],
js: [
// bower:js
'public/lib/angular/angular.js',
'public/lib/angular-resource/angular-resource.js',
'public/lib/angular-animate/angular-animate.js',
Expand All @@ -16,6 +19,7 @@ module.exports = {
'public/lib/angular-bootstrap/ui-bootstrap-tpls.js',
'public/lib/angular-file-upload/dist/angular-file-upload.js',
'public/lib/owasp-password-strength-test/owasp-password-strength-test.js'
// endbower
],
tests: ['public/lib/angular-mocks/angular-mocks.js']
},
Expand Down
4 changes: 4 additions & 0 deletions config/assets/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ module.exports = {
client: {
lib: {
css: [
// bower:css
'public/lib/bootstrap/dist/css/bootstrap.min.css',
'public/lib/bootstrap/dist/css/bootstrap-theme.min.css',
// endbower
],
js: [
// bower:js
'public/lib/angular/angular.min.js',
'public/lib/angular-resource/angular-resource.min.js',
'public/lib/angular-animate/angular-animate.min.js',
Expand All @@ -16,6 +19,7 @@ module.exports = {
'public/lib/angular-bootstrap/ui-bootstrap-tpls.min.js',
'public/lib/angular-file-upload/dist/angular-file-upload.min.js',
'public/lib/owasp-password-strength-test/owasp-password-strength-test.js'
// endbower
]
},
css: 'public/dist/application.min.css',
Expand Down
44 changes: 43 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,48 @@ gulp.task('imagemin', function () {
.pipe(gulp.dest('public/dist/img'));
});

// wiredep task to default
gulp.task('wiredep', function () {
return gulp.src('config/assets/default.js')
.pipe(plugins.wiredep({
ignorePath: '../../'
}))
.pipe(gulp.dest('config/assets/'));
});

// wiredep task to production
gulp.task('wiredep:prod', function () {
return gulp.src('config/assets/production.js')
.pipe(plugins.wiredep({
ignorePath: '../../',
fileTypes: {
js: {
replace: {
css: function (filePath) {
var minFilePath = filePath.replace('.css', '.min.css');
var fullPath = path.join(process.cwd(), minFilePath);
if (!fs.existsSync(fullPath)) {
return '\'' + filePath + '\',';
} else {
return '\'' + minFilePath + '\',';
}
},
js: function (filePath) {
var minFilePath = filePath.replace('.js', '.min.js');
var fullPath = path.join(process.cwd(), minFilePath);
if (!fs.existsSync(fullPath)) {
return '\'' + filePath + '\',';
} else {
return '\'' + minFilePath + '\',';
}
}
}
}
}
}))
.pipe(gulp.dest('config/assets/'));
});

// Copy local development environment config example
gulp.task('copyLocalEnvConfig', function () {
var src = [];
Expand Down Expand Up @@ -339,7 +381,7 @@ gulp.task('lint', function (done) {

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

// Run the project tests
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"lodash": "~4.3.0",
"lusca": "~1.3.0",
"method-override": "~2.3.5",
"gulp-wiredep": "~0.0.0",
"mocha": "~2.4.5",
"mongoose": "~4.4.3",
"morgan": "~1.6.1",
Expand Down

0 comments on commit 3d199ea

Please sign in to comment.