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

Feaure(grunt): Wiredep task for grunt #1402

Merged
merged 8 commits into from
Jul 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions config/assets/default.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
'use strict';

/* eslint comma-dangle:[0, "only-multiline"] */

module.exports = {
client: {
lib: {
css: [
// bower:css
'public/lib/bootstrap/dist/css/bootstrap.css',
'public/lib/bootstrap/dist/css/bootstrap-theme.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',
'public/lib/angular-bootstrap/ui-bootstrap-tpls.js',
'public/lib/angular-file-upload/dist/angular-file-upload.min.js',
'public/lib/angular-messages/angular-messages.js',
'public/lib/angular-mocks/angular-mocks.js',
'public/lib/angular-resource/angular-resource.js',
'public/lib/angular-ui-router/release/angular-ui-router.js',
'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'
'public/lib/owasp-password-strength-test/owasp-password-strength-test.js',
// endbower
],
tests: ['public/lib/angular-mocks/angular-mocks.js']
Expand Down
13 changes: 8 additions & 5 deletions config/assets/production.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
'use strict';

/* eslint comma-dangle:[0, "only-multiline"] */

module.exports = {
client: {
lib: {
css: [
// bower:css
'public/lib/bootstrap/dist/css/bootstrap.min.css',
'public/lib/bootstrap/dist/css/bootstrap-theme.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',
'public/lib/angular-messages/angular-messages.min.js',
'public/lib/angular-ui-router/release/angular-ui-router.min.js',
'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'
'public/lib/angular-messages/angular-messages.min.js',
'public/lib/angular-mocks/angular-mocks.js',
'public/lib/angular-resource/angular-resource.min.js',
'public/lib/angular-ui-router/release/angular-ui-router.min.js',
'public/lib/owasp-password-strength-test/owasp-password-strength-test.js',
// endbower
]
},
Expand Down
41 changes: 38 additions & 3 deletions gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ var _ = require('lodash'),
testAssets = require('./config/assets/test'),
testConfig = require('./config/env/test'),
fs = require('fs'),
path = require('path');
path = require('path'),
wiredep = require('wiredep');

module.exports = function (grunt) {
// Project Configuration
Expand Down Expand Up @@ -74,6 +75,34 @@ module.exports = function (grunt) {
}
}
},
wiredep: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were we not using wiredep in Grunt before?

fileTypes: {
src: 'config/assets/default.js',
ignorePath: '../../',
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 + '\',';
}
}
}
}
}
},
nodemon: {
dev: {
script: 'server.js',
Expand Down Expand Up @@ -228,7 +257,6 @@ module.exports = function (grunt) {

// Load NPM tasks
require('load-grunt-tasks')(grunt);
grunt.loadNpmTasks('grunt-protractor-coverage');

// Make sure upload directory exists
grunt.task.registerTask('mkdir:upload', 'Task that makes sure upload directory exists.', function () {
Expand Down Expand Up @@ -288,8 +316,15 @@ module.exports = function (grunt) {
// Lint CSS and JavaScript files.
grunt.registerTask('lint', ['sass', 'less', 'eslint', 'csslint']);

grunt.registerMultiTask('wiredep', 'Inject Bower dependencies.', function () {
this.requiresConfig(['wiredep', this.target, 'src']);

var options = this.options(this.data);
wiredep(options);
});

// Lint project files and minify them into two production files.
grunt.registerTask('build', ['env:dev', 'lint', 'ngAnnotate', 'uglify', 'cssmin']);
grunt.registerTask('build', ['env:dev', 'wiredep', 'lint', 'ngAnnotate', 'uglify', 'cssmin']);

// Run the project tests
grunt.registerTask('test', ['env:test', 'lint', 'mkdir:upload', 'copy:localConfig', 'server', 'mochaTest', 'karma:unit', 'protractor']);
Expand Down
5 changes: 3 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var _ = require('lodash'),
}
}),
pngquant = require('imagemin-pngquant'),
wiredep = require('wiredep').stream,
path = require('path'),
endOfLine = require('os').EOL,
protractor = require('gulp-protractor').protractor,
Expand Down Expand Up @@ -199,7 +200,7 @@ gulp.task('imagemin', function () {
// wiredep task to default
gulp.task('wiredep', function () {
return gulp.src('config/assets/default.js')
.pipe(plugins.wiredep({
.pipe(wiredep({
ignorePath: '../../'
}))
.pipe(gulp.dest('config/assets/'));
Expand All @@ -208,7 +209,7 @@ gulp.task('wiredep', function () {
// wiredep task to production
gulp.task('wiredep:prod', function () {
return gulp.src('config/assets/production.js')
.pipe(plugins.wiredep({
.pipe(wiredep({
ignorePath: '../../',
fileTypes: {
js: {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"glob": "~7.0.0",
"grunt": "~1.0.1",
"grunt-cli": "~1.2.0",
"gulp-wiredep": "~0.0.0",
"helmet": "~1.3.0",
"jasmine-core": "~2.4.1",
"lodash": "~4.6.1",
Expand All @@ -76,7 +75,8 @@
"socket.io": "~1.4.5",
"swig": "~1.4.2",
"validator": "~5.1.0",
"winston": "^2.2.0"
"winston": "^2.2.0",
"wiredep": "~4.0.0"
},
"devDependencies": {
"coveralls": "~2.11.6",
Expand Down