使用Grunt的AppCache Manifest为Src添加时间戳

时间:2016-02-16 09:53:33

标签: javascript html gruntjs html5-appcache offline-caching

我正在为我的应用程序创建一个清单文件。每当我执行grunt注入器任务时,它将为js和css url添加时间戳,删除缓存的文件。现在我在清单文件中也需要这个相同的URL。

My Grunt清单任务:

appcache: {
    options: {
        basePath: '<%= global.paths.dist %>/html',
        network: ['http://*', 'https://*'],
        preferOnline: true,
        verbose: true,
        timestamp: true,
        hash: true,
        master: ['index-vendor.html']
    },
    all: {
      dest: '<%= global.paths.dist %>/manifest.appcache',
      cache: {
        patterns: [
          '<%= global.paths.dist %>/**/*', 
          '!<%= global.paths.dist %>/js/bower_components/angular-i18n/**/*'
        ],
        literals: '/'
      }
    }
} 

我的结果如下:

CACHE MANIFEST
# rev 1 - 2016-02-16T09:30:49.337Z

CACHE:

index.html
../js/main.js
../styles/css/application.css
../styles/images/loading.gif
../styles/images/logo.svg
../styles/images/progressbar.gif
/

SETTINGS:
prefer-online 

我的预期结果是:

CACHE MANIFEST
# rev 1 - 2016-02-16T09:30:49.337Z

CACHE:

index.html
../js/main.js?v=1446033543134
../styles/css/application.css?v=1446033543134
../styles/images/loading.gif?v=1446033543134
../styles/images/logo.svg?v=1446033543134
../styles/images/progressbar.gif?v=1446033543134
/

SETTINGS:
prefer-online

有人可以给我一个解决方案吗?

0 个答案:

没有答案