Skip to content

Commit

Permalink
Fixed JS asset hash is not in sync with PHP one. (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianmarz authored Aug 25, 2020
1 parent b56e00c commit c76d0de
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = function (gulp) {
$.minimist = require('minimist');
$.path = require('path');
$.magicImporter = require('node-sass-magic-importer');
$.twigAsset = require('@netzstrategen/twig-asset')();

let tasks = [
'clean',
Expand Down
12 changes: 8 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
"@babel/preset-env": "^7.9.5",
"@frctl/fractal": "^1.2.1",
"@netzstrategen/fractal-twig": "^2.2.4",
"@netzstrategen/twig-asset": "^1.0.0",
"del": "^3.0.0",
"gulp": "^4.0.0",
"gulp-autoprefixer": "^4.0.0",
"gulp-babel": "^8.0.0",
"gulp-clean-css": "^4.3.0",
"gulp-concat": "^2.6.1",
"gulp-css-url-custom-hash": "^0.0.5",
"gulp-css-url-custom-hash": "netzstrategen/gulp-css-url-custom-hash",
"gulp-eslint": "^5.0.0",
"gulp-if": "^2.0.2",
"gulp-imagemin": "^3.1.1",
Expand Down
4 changes: 4 additions & 0 deletions tasks/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const getOptions = require('../lib/getOptions');
const registerTaskWithProductionMode = require('../lib/registerTaskWithProductionMode');
const path = require('path');

module.exports = (gulp, $, pkg) => {
const reportError = require('../lib/error.js');
Expand Down Expand Up @@ -54,6 +55,9 @@ module.exports = (gulp, $, pkg) => {
.pipe($.replace(copyrightPlaceholder, copyrightNotice))
.pipe($.if(options.concat, $.concat(pkg.title.toLowerCase().replace(/[^a-z]/g,'') + '.css')))
.pipe($.cssUrlCustomHash({
customHash: (fileName, hash, filePath) => {
return path.basename($.twigAsset.asset(filePath));
},
targetFileType: ['jpe?g', 'png', 'webp', 'svg', 'gif', 'ico', 'otf', 'ttf', 'eot', 'woff2?'],
}))
.pipe(gulp.dest(pkg.gulpPaths.styles.dest))
Expand Down

0 comments on commit c76d0de

Please sign in to comment.