Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix paths in hashed files #211

Merged
merged 4 commits into from
Jan 3, 2017
Merged

Fix paths in hashed files #211

merged 4 commits into from
Jan 3, 2017

Conversation

richardhinkamp
Copy link
Contributor

@richardhinkamp richardhinkamp commented Nov 7, 2016

Fixes for #207

It correctly identifies all relative paths from the source file to the hashed filename, including the absolute path.

The replace is smarter now, a replace of "css/app.css" would also replace "lib/css/app.css", which is incorrect. So now the filename is only replaced in these cases, enclosed by:
"{file}"
'{file}'
({file}) (css url(...))
={file}> (unquoted html attribute)
={file}\s (unquoted html attribute followed by more attributes)
Since the filename may contain a querystring, the closing char may also be a '?'.
I created a new unit test for this.

If a file is copied to a hashed filename, replacing will now happen in the hashed file instead of the original file, since the original file will not be used (and maybe even be deleted).
If a full filename is specified as source instead of a wildcard and that file is busted, the source cannot be found when replacing in files. It now correctly handles this cases and translated the filename to the busted filename.

All the test still work and the test project in the issue also works as expected. I hope this a correct change which can be merged, I would love to get some feedback on it.

Richard

Working with all relative paths + absolute path
Replace in hashed files instead of original files
If css/app.css is to be replaced with a hashed version, don't replace css/app.css in subdirs.
@richardhinkamp
Copy link
Contributor Author

@HollandBen are you willing to accept (or at least review) this PR? Can I help to get this merged?

@zacyang
Copy link

zacyang commented Dec 8, 2016

Can we please merge this PR, I have encountered the similar issue regarding the relative path as well. Thanks.

@richardhinkamp
Copy link
Contributor Author

@HollandBen are you planning to do something with this PR?

@benhoIIand benhoIIand merged commit ff443e9 into benhoIIand:master Jan 3, 2017
@benhoIIand
Copy link
Owner

benhoIIand commented Jan 5, 2017

Hi @richardhinkamp and @zacyang. It appears these changes have broken parsing of files that include an "alternate syntax" (#214). I've created a test for it that is currently failing and pushed it into the alternate-syntax-parsing-broken branch. Could either of you please have a look into fixing this - thanks.

@richardhinkamp
Copy link
Contributor Author

Thanks for merging @HollandBen ! I will comment in #214 about that issue

@richardhinkamp richardhinkamp deleted the fix-paths-in-hashed-files branch January 28, 2017 22:04
hemberger added a commit to hemberger/smr that referenced this pull request Feb 16, 2021
The behavior of this package has changed since v1.4.1, such that the
replacements are made in files with a strict adherence to relative
paths from the `baseDir` option. Since many of our PHP files aren't
located where they are served from (e.g. templates, includes, etc.),
grunt-cache-bust doesn't bust these files anymore.

The easiest fix is reference all JS/CSS with absolute URL paths (e.g.
`css/Default.css` -> `/css/Default.css`). While this is not an ideal
solution, due to its degradation of our support for serving the game
from a subdirectory (e.g. `http://localhost/smr` instead of just
`http://localhost`), it solves the problem for our current dev and
production configurations.

See benhoIIand/grunt-cache-bust#211 for the
PR that introduced this breaking change.

See benhoIIand/grunt-cache-bust#236 for a
summary of how this change impacted our usage.

Thanks to @Page- for the deep dive into grunt-cache-bust!
hemberger added a commit to hemberger/smr that referenced this pull request Feb 17, 2021
The behavior of this package has changed since v1.4.1, such that the
replacements are made in files with a strict adherence to relative
paths from the `baseDir` option. Since many of our PHP files aren't
located where they are served from (e.g. templates, includes, etc.),
grunt-cache-bust doesn't bust these files anymore.

The easiest fix is reference all JS/CSS with absolute URL paths (e.g.
`css/Default.css` -> `/css/Default.css`). While this is not an ideal
solution, due to its degradation of our support for serving the game
from a subdirectory (e.g. `http://localhost/smr` instead of just
`http://localhost`), it solves the problem for our current dev and
production configurations.

See benhoIIand/grunt-cache-bust#211 for the
PR that introduced this breaking change.

See benhoIIand/grunt-cache-bust#236 for a
summary of how this change impacted our usage.

Thanks to @Page- for the deep dive into grunt-cache-bust!
hemberger added a commit to smrealms/smr that referenced this pull request Feb 21, 2021
The behavior of this package has changed since v1.4.1, such that the
replacements are made in files with a strict adherence to relative
paths from the `baseDir` option. Since many of our PHP files aren't
located where they are served from (e.g. templates, includes, etc.),
grunt-cache-bust doesn't bust these files anymore.

The easiest fix is reference all JS/CSS with absolute URL paths (e.g.
`css/Default.css` -> `/css/Default.css`). While this is not an ideal
solution, due to its degradation of our support for serving the game
from a subdirectory (e.g. `http://localhost/smr` instead of just
`http://localhost`), it solves the problem for our current dev and
production configurations.

See benhoIIand/grunt-cache-bust#211 for the
PR that introduced this breaking change.

See benhoIIand/grunt-cache-bust#236 for a
summary of how this change impacted our usage.

Thanks to @Page- for the deep dive into grunt-cache-bust!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants