Grunt - How to update html files references within js files using grunt cache bust?

后端 未结 3 569
北荒
北荒 2021-01-14 18:19

In my js files I have references to HTML files, like window.location. I would like grunt cache bust to update that reference and add the hash data, so the loaded page is the

3条回答
  •  梦毁少年i
    2021-01-14 19:09

    I worked on a project which used Grunt cache bust to bust filenames in JS files. The configuration looked like this

    cacheBust : {
        revProd: {
            options: {
                assets: ['**/*.js', '!assets/js/config.constant.js','**/*.css','!assets/css/themes/*.css'],
                baseDir: 'standardversion',
                deleteOriginals: true,
                jsonOutput: true, // Output the original => new URLs to a JSON file
                jsonOutputFilename: 'grunt-cache-bust.json'
            },
            src: ['standardversion/index.html', 'standardversion/assets/js/config.contants.js']
    }
    

    Where my config.contants.js file has paths like

    'propertiesCtrl': 'assets/views/properties/controllers/properties.controller.js',
    'propertyDetailsCtrl': 'assets/views/properties/controllers/propertyDetails.controller.js',
    'propertyAddCtrl': 'assets/views/properties/controllers/addProperty.controller.js',
    

    You can bust HTMLs by adding **/*.html to assets option

提交回复
热议问题