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

Commit

Permalink
feat(core): Add prod asset versioning (#1536)
Browse files Browse the repository at this point in the history
Asset versioning for prod - idea from #1509

Fixes #1509
  • Loading branch information
sujeethk authored and lirantal committed Oct 6, 2016
1 parent 6a6b630 commit b0c5ad9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
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 @@ -77,6 +77,7 @@
},
"devDependencies": {
"coveralls": "~2.11.6",
"del": "^2.2.2",
"eslint": "~2.2.0",
"eslint-config-airbnb": "~6.0.2",
"gulp": "~3.9.1",
Expand All @@ -97,6 +98,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

0 comments on commit b0c5ad9

Please sign in to comment.