Skip to content

Commit 92caf44

Browse files
Add gulp uglify to compress js into application.js. refs #19
Currently what this compresses is configured in the gulpfile, so when you add new bower components you need to add to the options.js.files array the path of the file that needs to be included in the uglification.
1 parent 9c96f2d commit 92caf44

10 files changed

Lines changed: 85 additions & 316 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ node_modules
2828
.DS_Store
2929
.lock-wscript
3030
.service-credentials
31+
32+
bower_components

bower.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "JavaScript.com",
3+
"version": "0.0.0",
4+
"homepage": "https://github.com/codeschool/JavaScript.com",
5+
"authors": [
6+
"Code School"
7+
],
8+
"license": "MIT",
9+
"private": true,
10+
"ignore": [
11+
"**/.*",
12+
"node_modules",
13+
"bower_components",
14+
"test",
15+
"tests"
16+
],
17+
"dependencies": {
18+
"angular": "~1.3.14",
19+
"jquery": "~2.1.3"
20+
}
21+
}

gulpfile.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ var sass = require('gulp-sass');
1414
var minifycss = require('gulp-minify-css');
1515
var rename = require('gulp-rename');
1616
var autoprefixer = require('gulp-autoprefixer');
17+
var uglify = require('gulp-uglify');
18+
var concat = require('gulp-concat');
1719

1820
// -------------------------------------
1921
// Variables
@@ -30,6 +32,15 @@ var options = {
3032
sass: {
3133
files: ['public/stylesheets/*.sass', 'public/stylesheets/**/*.sass'],
3234
destination: 'public/stylesheets'
35+
},
36+
37+
js: {
38+
files: ['bower_components/angular/angular.js',
39+
'bower_components/jquery/dist/jquery.js',
40+
'public/javascripts/**/*.js'],
41+
42+
destFile: 'application.js',
43+
destDir: 'public/javascripts'
3344
}
3445

3546
};
@@ -72,3 +83,16 @@ gulp.task('sass', function () {
7283
}))
7384
.pipe(gulp.dest(options.sass.destination));
7485
});
86+
87+
// -------------------------------------
88+
// Task: JavaScript Uglify
89+
// -------------------------------------
90+
91+
gulp.task('uglify', function() {
92+
options.js.files.push('!public/javascripts/application.js');
93+
94+
gulp.src(options.js.files)
95+
.pipe(concat('application.js'))
96+
.pipe(uglify())
97+
.pipe(gulp.dest(options.js.destDir));
98+
});

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@
2929
"devDependencies": {
3030
"gulp": "^3.8.11",
3131
"gulp-autoprefixer": "^2.1.0",
32+
"gulp-concat": "^2.5.2",
3233
"gulp-minify-css": "^0.4.6",
3334
"gulp-rename": "^1.2.0",
3435
"gulp-sass": "^1.3.3",
36+
"gulp-uglify": "^1.1.0",
3537
"gulp-watch": "^4.1.1"
3638
}
3739
}

public/javascripts/angular.min.js

Lines changed: 0 additions & 282 deletions
This file was deleted.

public/javascripts/application.js

Lines changed: 9 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/javascripts/jquery.min.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

public/javascripts/main.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
$(function() {
2+
// Hide sponsor links
3+
$('tr[style="background-color: #faf9dc;"]').hide();
4+
})
5+
6+
angular.module('javascriptcom', []);
7+
8+
angular.module('javascriptcom').directive('jsCourse', function() {
9+
return {
10+
templateUrl: 'templates/js-course.html',
11+
replace: true
12+
};
13+
});
14+
15+
angular.module('javascriptcom').directive('jsInstructions', function() {
16+
return {
17+
templateUrl: 'templates/js-instructions.html',
18+
replace: true
19+
};
20+
});
21+
22+
angular.module('javascriptcom').directive('jsConsole', function() {
23+
return {
24+
templateUrl: 'templates/js-console.html',
25+
replace: true
26+
};
27+
});

views/layouts/layout-bleed.jade

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,4 @@ html
1212
main.content
1313
block content
1414

15-
script(src='/javascripts/jquery.min.js')
16-
script(src='/javascripts/angular.min.js')
1715
script(src='/javascripts/application.js')

views/layouts/layout.jade

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@ html
1212
main.content
1313
block content
1414

15-
script(src='/javascripts/jquery.min.js')
1615
script(src='/javascripts/application.js')

0 commit comments

Comments
 (0)