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

Help configuring to replace references. #239

Open
tim-bradley opened this issue Jun 9, 2018 · 3 comments
Open

Help configuring to replace references. #239

tim-bradley opened this issue Jun 9, 2018 · 3 comments

Comments

@tim-bradley
Copy link

I am seeking help to configure properly.

This is busting assets just fine, but I can't get it to update the references to the new busted urls.

My jekyll static site project:

project root
|___ [various files and folders for project]
|___ "_staging/"  //<- dir where complete site is after build, minifying, etc
|            |___ assets/
|            |          |___ js/
|            |          |___ images/
|            |          |___ css/ 
|            |____ [various html and other files and folders for site]
|___ "_public/" // <- dir I'd ideally like complete cache busted site ready for upload

At the moment I am just trying to bust successfully in situ in _staging/ and not outputing to sibling _public directory.

The task in my gruntfile is:

cacheBust: {
  options: {
    assets: ['assets/**/*'],
    baseDir: './_staging/',
    deleteOriginals: true,
  },
  taskName: {
    files: [{
      expand: true,
      cwd: '_staging/',
      src: ['**/*.{html,js,css,xml,txt}',]
    }]
  }
},

As above, this is cache busting all the files in the assets directory at root/_staging/assets/ just fine, and such that they all have md5 fingerprints and non-busted assets are deleted.

However, the references to the assets (in html, sw.js etc) are not being changed.

For example, in the processed home page index.html here (root/_staging/index.html):

project root
|
|___ "_staging/"  //<- dir where complete site is after build, minifying, etc
|            |___ index.html
...

...the reference to the style sheet is still:

<link rel="stylesheet" href="https://www.mysite.org/assets/css/main.css">

instead of desired:

<link rel="stylesheet" href="https://www.mysite.org/assets/css/main.4709430bf780d8b5.css">

Could someone help me to configure this properly to get references to change?

Thank you for any help in advance.

@ArmorDarks
Copy link

It won't work with absolute URLs like https://www.mysite.org/assets/css/main.css.

To make plugin recognize files, the paths to the files must match. In this case, https://www.mysite.org/assets/css/main.css seems to it like a completely different asset. It can't know, that https://www.mysite.org/assets/css/main.css and /assets/css/main.css are same files.

Just as a side note, there is no reason to use absolute paths for assets, unless some special cases (like URLs for structured data formats). Just use root-relative paths like /assets/css/main.css and let server resolve domain.

@tim-bradley
Copy link
Author

Oh crap, you're right. It looks for strings enclosed by particular character sets.

Weird that this limitation was not warned of in README or, alternatively, that an option made to allow setting a basepath - which would have resolved this.

But thanks - I'll think about what to do from here.

@ArmorDarks
Copy link

ArmorDarks commented Jun 9, 2018

I've created an issue about #240

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

No branches or pull requests

2 participants