Skip to content

Commit

Permalink
Merge pull request #390 from sphereio/fingerprint-assets-384
Browse files Browse the repository at this point in the history
Enable asset fingerprinting, closes #384
  • Loading branch information
lauraluiz committed Mar 3, 2016
2 parents 3071609 + 1a1833a commit b2d5ebd
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 12 deletions.
12 changes: 8 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ module.exports = function(grunt) {

grunt.registerTask('default', ['build', 'watch']);

grunt.registerTask('build', ['clean', 'build-images', 'build-assets', 'build-templates']);
grunt.registerTask('build-images', ['clean:images', 'copy:images', 'imagemin']);
grunt.registerTask('build-assets', ['clean:assets', 'copy:assets', 'sass', 'postcss', 'uglify']);
grunt.registerTask('build-templates', ['clean:templates', 'copy:templates', 'copy:others', 'json-refs', 'generate-html']);
grunt.registerTask('build', ['clean', 'internal-build-images', 'internal-build-assets', 'internal-build-templates', 'assetFingerprint']);
grunt.registerTask('build-images', ['clean:images', 'internal-build-images', 'assetFingerprint:images']);
grunt.registerTask('build-assets', ['clean:assets', 'internal-build-assets', 'assetFingerprint:assets']);
grunt.registerTask('build-templates', ['clean:templates', 'internal-build-templates', 'assetFingerprint']);

grunt.registerTask('release-composer', ['build', 'copy:composer']);
grunt.registerTask('webjars', ['build', 'maven:webjars']);
Expand All @@ -29,6 +29,10 @@ module.exports = function(grunt) {

grunt.registerTask('publish', ['gh-pages-clean', 'build', 'gh-pages']);

grunt.registerTask('internal-build-images', ['copy:images', 'imagemin']);
grunt.registerTask('internal-build-assets', ['copy:assets', 'sass', 'postcss', 'uglify']);
grunt.registerTask('internal-build-templates', ['copy:templates', 'copy:others', 'json-refs', 'generate-html']);

};

function loadConfig(path) {
Expand Down
2 changes: 0 additions & 2 deletions input/assets/css/main.min.css

This file was deleted.

1 change: 0 additions & 1 deletion input/assets/css/main.min.css.map

This file was deleted.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"autoprefixer": "^6.2.3",
"glob": "^6.0.4",
"grunt": "^0.4.5",
"grunt-asset-fingerprint": "^0.2.1",
"grunt-compile-handlebars": "^2.0.0",
"grunt-contrib-clean": "^0.7.0",
"grunt-contrib-copy": "^0.8.2",
Expand Down
50 changes: 50 additions & 0 deletions tasks/options/assetFingerprint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module.exports = {

options: {
manifestPath: "output/assets.json",
findAndReplaceFiles: [
"output/assets/css/**/*.{css,map}",
"output/assets/js/**/*.js",
"output/templates/**/*.hbs",
"output/site/**/*.html"
],
keepOriginalFiles: false
},

images: {
files: [
{
expand: true,
cwd: "output/assets",
src: [
"img/**/*",
"!img/favicon.ico"
],
dest: "output/assets"
}
]
},

assets: {
files: [
{
expand: true,
cwd: "output/assets",
src: [
"fonts/**/*",
"js/**/*.js"
],
dest: "output/assets"
},
{
expand: true,
cwd: "output/assets/css",
src: [
"**/*.css"
],
dest: "output/assets/css"
}
]
}

}
10 changes: 8 additions & 2 deletions tasks/options/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,19 @@ module.exports = {
expand: true,
cwd: 'input/',
dest: 'output/',
src: 'assets/css/*.css'
src: 'assets/css/**/*.css'
},
{
expand: true,
cwd: 'input/assets/css/',
dest: 'output/assets/css/sass/',
src: '**/*.scss'
},
{
expand: true,
cwd: 'input/',
dest: 'output/',
src: 'assets/js/*.js'
src: 'assets/js/**/*.js'
},
{
expand: true,
Expand Down
2 changes: 0 additions & 2 deletions tasks/options/postcss.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ module.exports = {
// 'grunt-postcss': optimizes CSS files with vendor prefixes

options: {
map: true,
//diff: true,
processors: require('autoprefixer')
},

Expand Down
2 changes: 1 addition & 1 deletion tasks/options/sass.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
style: 'compressed'
},
files: {
'output/assets/css/main.min.css' : 'input/assets/css/main.scss'
'output/assets/css/main.min.css' : 'output/assets/css/sass/main.scss'
}
}

Expand Down

0 comments on commit b2d5ebd

Please sign in to comment.