Coder Social home page Coder Social logo

grunt-cache-busting's People

Contributors

benhollander avatar kevindice avatar mackenco avatar paultondeur avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

grunt-cache-busting's Issues

[RequireJS use case] template search regex is too greedy

Great task^^

I had a minor scuffle with the template replace regex. I am using RequireJS standard script tag:

<script data-main="PATH/TO/MAIN/CACHEBUSTED/src.js" src="PATH/TO/requirejs.js"></script>

When I ran grunt-cache-busting with the following params:

replace: ['my/templates.html'],
replacement: 'src.js',
file: 'PATH/TO/MAIN/CACHEBUSTED/src.js',
cleanup: true

The regex ate my requirejs src attr and gave me:

<script data-main="PATH/TO/MAIN/CACHEBUSTED/src-HASH.js">

The fix is simple: put src before data-main.
Maybe by design but, it should probably be noted somewhere if so.

I wish I could be more helpful and provide a fixed fork but I am swamped right now ใ…œใ… 

Re-running cache bust doesn't update html file.

Hi there,

I've been applying cache-busting in my grunt workflow for my styles.css file. Running the task first time round works perfectly, appending the hash to both the css file and the html file path.

However, when re-running the task after updating the css file, the file hash is appended, and the old one is cleaned up. However, the html path keeps the original hash. I suspect this is due to the search string in the 'replacement' no longer generating a hit due to the presence of the hash?

'cache-busting': {
css: {
replace: ['inc/head.php'],
replacement: '/css/styles.min.css', //no hash in search string, so no update in html?
file: 'css/styles.min.css',
cleanup: true
}
},

Is there a clean work around?

Can't overwrite old path

Hi guys, thanks for the plugin. Trying to use it on our site likeso:

'cache-busting': {
css: {
replace: ['<%= config.themeroot %>/Layouts/default.ctp'],
replacement: 'filename.min.css',
file: '<%= config.webroot %>/css/filename.min.css'
}
}

So it works great the first grunt, updating the path in default.ctp to 'webroot/css/filename.min-MD5-HASH.css', but every subsequent grunt the filename never changes again, guessing because the process is looking for 'filename.min.css'

Is there a wildcard or other method I could use of changing the existing filename path?

Cache cleanup

Is there a way for the cache bust to clean up after itself (i.e. delete the previously hashed file?).

If reference is not the last attribute in an HTML tag, task enters infinite loop

This was my replacement:

encoding_template: {
        replace: ['public/views/includes/header.html'],
        replacement: 'encoding_template.html',
        file: 'public/views/includes/encoding.html'
      }

This was the reference inside header.html:

<li class="dropdown" data-ng-controller="EncodingController" data-ng-include="'views/includes/encoding_template.html'" data-ng-show="currencyIsBCH"></li>

Like this, when running the encoding_template task, grunt entered an infinite loop and I had to kill it. The workaround I discovered was moving data-ng-include to the end of the attribute list:

<li class="dropdown" data-ng-controller="EncodingController" data-ng-show="currencyIsBCH" data-ng-include="'views/includes/encoding_template.html'"></li>

This way, it works.

Having a directory with the same name as the file breaks the replacement

Example:

bust: {
    replace: ['my.html'],
    replacement: 'jquery.js',
    file: 'somewhere/jquery.js'
}

The html

<script src="jquery/jquery.js"></script>

is being transformed to:

<script src="jquery-HASH.js"></script>
<!-- instead of -->
<script src="jquery/jquery-HASH.js"></script>

FYI, I'm not really trying to cache-bust jquery, I just chose it as an example.
I saw in the code that the extension is pretty coupled to everything else, so it wasn't straight forward to fix it.

Thanks for plugin by the way ;)

Add instead of replace

Is is possible to add an option to add the hashed file instead of writing over the file. This is creating an issue when using grunt-contrib-watch since it's looking for the original version which is overwritten.

Only 1st replacement done

Hello,

I use grunt-cache-busting tasks also for cache cleaning of sprite image (when I create new sprite by another task, the result is new Less file, but referencing to sprite image with no version), so I clean Less file by:

..
spritespngincss: {
                replace: ['www/css/sprites/partners.less'],
                replacement: 'partners.png',
                file: 'www/images/sprites/partners.png',
                get_param: true,
            }

*But cache-busting makes changes only for first apperance in file: *

/*partners.less*/
.partners-akc {
  display: block;
  background-image: url(../images/sprites/partners.png?v=dd7870f2a3d830f82b7bfbad54d34fcc);
  background-position: -300px -60px;
  width: 150px;
  height: 60px;
  box-sizing: border-box;
}
.partners-apek {
  display: block;
  background-image: url(../images/sprites/partners.png);
  background-position: -150px -285px;
  width: 150px;
  height: 60px;
  box-sizing: border-box;
}

Is there some parameter to force replace all apperance?

Thanks,
Vaclav!

Cache Busting Error: Primodials not Defined.

Screenshot 2020-03-09 at 2 19 42 PM

Hi
I'm encountering the error when I run the command grunt proxy --config="dev".
I have tried to install grunt 0.4.1
node version 12.16.0
npm version 6.14.2

I have tried to install grunt-cache-busting manually, but I still face the same issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.