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

feat(core): Add prod asset versioning #1536

Merged
merged 1 commit into from
Oct 6, 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
8 changes: 5 additions & 3 deletions config/assets/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,25 @@ module.exports = {
// bower:css
'public/lib/bootstrap/dist/css/bootstrap.min.css',
'public/lib/bootstrap/dist/css/bootstrap-theme.min.css',
'public/lib/ng-img-crop/compile/minified/ng-img-crop.css',
// endbower
],
js: [
// bower:js
'public/lib/angular/angular.min.js',
'public/lib/angular-animate/angular-animate.min.js',
'public/lib/angular-bootstrap/ui-bootstrap-tpls.min.js',
'public/lib/angular-file-upload/dist/angular-file-upload.min.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/ng-file-upload/ng-file-upload.min.js',
'public/lib/ng-img-crop/compile/minified/ng-img-crop.js',
'public/lib/owasp-password-strength-test/owasp-password-strength-test.js',
// endbower
]
},
css: 'public/dist/application.min.css',
js: 'public/dist/application.min.js'
css: 'public/dist/application*.min.css',
js: 'public/dist/application*.min.js'
}
};
2 changes: 1 addition & 1 deletion config/lib/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ module.exports.initHelmetHeaders = function (app) {
*/
module.exports.initModulesClientRoutes = function (app) {
// Setting the app router and static folder
app.use('/', express.static(path.resolve('./public')));
app.use('/', express.static(path.resolve('./public'), { maxAge: 86400000 }));

// Globbing static routing
config.folders.client.forEach(function (staticPath) {
Expand Down
4 changes: 4 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var _ = require('lodash'),
protractor = require('gulp-protractor').protractor,
webdriver_update = require('gulp-protractor').webdriver_update,
webdriver_standalone = require('gulp-protractor').webdriver_standalone,
del = require('del'),
KarmaServer = require('karma').Server;

// Local settings
Expand Down Expand Up @@ -159,13 +160,15 @@ gulp.task('uglify', function () {
defaultAssets.client.js,
defaultAssets.client.templates
);
del(['public/dist/*']);

return gulp.src(assets)
.pipe(plugins.ngAnnotate())
.pipe(plugins.uglify({
mangle: false
}))
.pipe(plugins.concat('application.min.js'))
.pipe(plugins.rev())
.pipe(gulp.dest('public/dist'));
});

Expand All @@ -174,6 +177,7 @@ gulp.task('cssmin', function () {
return gulp.src(defaultAssets.client.css)
.pipe(plugins.csso())
.pipe(plugins.concat('application.min.css'))
.pipe(plugins.rev())
.pipe(gulp.dest('public/dist'));
});

Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
},
"devDependencies": {
"coveralls": "~2.11.6",
"del": "^2.2.2",
"eslint": "~2.2.0",
"eslint-config-airbnb": "~6.0.2",
"grunt-concurrent": "~2.0.0",
Expand Down Expand Up @@ -116,6 +117,7 @@
"gulp-nodemon": "~2.1.0",
"gulp-protractor": "~3.0.0",
"gulp-rename": "~1.2.2",
"gulp-rev": "^7.1.2",
"gulp-sass": "~2.3.0",
"gulp-uglify": "~1.5.2",
"gulp-util": "~3.0.7",
Expand Down