grunt-cache-bust icon indicating copy to clipboard operation
grunt-cache-bust copied to clipboard

References in Subfolders not getting updated

Open chibui opened this issue 5 years ago • 4 comments

I can't seem to get references in subfolders to update with the hashed name.

My config is :

cacheBust: { 
           test: {
               options: {
                   deleteOriginals: true,
                   assets: ['**/**.{css,html}'],
                   baseDir: 'dist'
               },
               files: [{
                   expand: true,
                   cwd: 'dist',
                   src: ['**/*.{html, js}',]
               }]
           }
       }

My app structure prior to running task :

app|
---|dist|
--------|child.html
--------|child.css
--------|foo|
------------|foo.html
------------|foo.css
------------|bar|
----------------|bar.html
----------------|bar.css
--------|noop|
---------------|noop.html
---------------|noop.css

When I run the task, all the file are correctly renamed with the hash val. The issue is that with the exception of the reference in child.html being updated, none of the other references are updated.

foo.html

<!doctype html>
<html>
<head>
    <link href="foo.css" type="text/css" rel="stylesheet" />
</head>
<body>
<h2>FOO!!!</h2>
</body>
</html>

I've tried various configs but without any success. I've even tried to reference the source files directly.

files: [{
    expand: true,
    cwd: 'dist/',
    src: ['dist/foo/**/*.html', 'dist/noop/**/*.html']
 }]

and also

src: [ 'dist/foo/*.html', 'dist/noop/*.html']

Im using grunt-cache-bust v 1.7.0

Thanks in advance.

chibui avatar Sep 20 '18 02:09 chibui

+1 facing the same issue on grunt-cache-bust v 1.7.0. Any workarounds?

osamamaruf avatar Oct 24 '18 11:10 osamamaruf

+1 I faced the same issue. Seems like there is a PR https://github.com/hollandben/grunt-cache-bust/pull/245 which should fix it. We should wait for it to be merged soon.

pankaj-arunsingh avatar Nov 09 '18 03:11 pankaj-arunsingh

Running Windows and having the same issue, but the code from the PR doesn't seem to solve it for me. Instead, in node_modules\grunt-cache-bust\tasks\cachebust.js I changed the loop at line 134 to start from 0 instead of 1.

Made my own PR at https://github.com/hollandben/grunt-cache-bust/pull/250 - hopefully this helps someone else.

Taelkir avatar Feb 21 '19 13:02 Taelkir

I can also confirm that #250 works as expected (Linux).

dikaso avatar Jul 30 '19 11:07 dikaso