Coder Social home page Coder Social logo

custom-dev-tools / grunt-cache-killer Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 244 KB

Grunt cache killer is a Grunt plugin that circumvents http(s) cache problems when asset files (such as css, js and img files) are updated. This plugin automatically updates the specified asset filename(s) and any reference to them within your specified (template) files.

License: MIT License

JavaScript 83.22% HTML 16.78%
asset-management cache-busting grunt grunt-plugins gruntjs http-requests plugin

grunt-cache-killer's Introduction

Building Custom Developer Tools


Website     GitHub     Twitter     YouTube     CodePen     NPM     Packagist     StackOverflow     Buy me a coffee

Let's Make Something ...

Scripts and programs to simplify and streamline your development environments and build processes


grunt-cache-killer's People

Contributors

custom-dev-tools avatar midnight-coding avatar

Stargazers

 avatar  avatar

Watchers

 avatar

grunt-cache-killer's Issues

Issue: In a special case the CSS file names are not replaced correctly in the HTML code

Hello,

I am working on a project that is based on HTML5 Boilerplate. Unfortunately, grunt-cache-killer is not correctly replacing CSS files names in index.php; this is due to a file named style.css, this file is part of HTML5 Boilerplate.

Before running the task:

<link rel="stylesheet" href="css/vendor/bootstrap-5.1.3.min.css">
<link rel="stylesheet" href="css/style.min.css">
<link rel="stylesheet" href="css/custom.min.css">

After:

<link rel="style.20220813212624.min.css">
<link rel="style.20220813212624.min.css">
<link rel="style.20220813212624.min.css">

This is the task's configuration:

    cacheKiller: {
      options: {
        mask: '{datetimestamp}',
        prepend: '.'
      },
      build: {
        files: {
          'dist/css/style[mask].min.css' : ['dist/index.php'],
          'dist/css/custom[mask].min.css' : ['dist/index.php']
        }
      }
    },

And this is the debug output:

[D] Options object: { prepend: '.', append: '', mask: '{datetimestamp}', length: -1 }

[D] Validating option types.
[D] Success..!

[D] Validating mask function type.
[D] Success..!

[D] Building tasks list.
[D] Working..!.

[D] Validating template filenames.
[D] Success..!

[D] Validating position of mask placeholder.
[D] Success..!

[D] Validating asset filename.
[D] Success..!

[D] Validating template filenames.
[D] Success..!

[D] Validating position of mask placeholder.
[D] Success..!

[D] Validating asset filename.
[D] Success..!

[D] Build tasks list.
[D] Success..!

[D] Tasks list object:
{
  '0': {
    asset: {
      name: {
        full: 'dist/css/style[mask].min.css',
        base: 'dist/css/',
        file: 'style[mask].min.css',
        pre: 'style',
        post: '.min.css'
      },
      mask: {
        prepend: '.',
        value: { raw: '20220813212624', computed: '20220813212624' },
        append: ''
      },
      rename: {
        from: { file: 'style.min.css', full: 'dist/css/style.min.css' },
        to: {
          file: 'style.20220813212624.min.css',
          full: 'dist/css/style.20220813212624.min.css'
        }
      }
    },
    templates: [ 'dist/index.php' ]
  },
  '1': {
    asset: {
      name: {
        full: 'dist/css/custom[mask].min.css',
        base: 'dist/css/',
        file: 'custom[mask].min.css',
        pre: 'custom',
        post: '.min.css'
      },
      mask: {
        prepend: '.',
        value: { raw: '20220813212624', computed: '20220813212624' },
        append: ''
      },
      rename: {
        from: { file: 'custom.min.css', full: 'dist/css/custom.min.css' },
        to: {
          file: 'custom.20220813212624.min.css',
          full: 'dist/css/custom.20220813212624.min.css'
        }
      }
    },
    templates: [ 'dist/index.php' ]
  }
}


[D] Synchronously renaming asset file.
[D] Success..!

>> build : Asset file 'style.min.css' renamed to 'style.20220813212624.min.css'.
[D] 
[D] Synchronously read contents of template.
[D] Success..!

[D] Replace template's matching content.
[D] Success..!

[D] Synchronously write contents to template.
[D] Success..!

>> build : Reference(s) updated in template file 'dist/index.php'.

[D] Synchronously renaming asset file.
[D] Success..!

>> build : Asset file 'custom.min.css' renamed to 'custom.20220813212624.min.css'.
[D] 
[D] Synchronously read contents of template.
[D] Success..!

[D] Replace template's matching content.
[D] Success..!

[D] Synchronously write contents to template.
[D] Success..!

>> build : Reference(s) updated in template file 'dist/index.php'.

Success..!

Done.

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.