gunta / grunt-manifest

Generates HTML5 Cache Manifest files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

manifest contains folder names

marcorinck opened this issue · comments

I have updated a project from grunt 0.3.x to 0.4.1 and grunt-contrib-manifest from 0.2 to the current version 0.4.0.

Now my appcache manifest contains not only files but directory names too which the browser can't download of course.

The configuration is basically the same as it was before and looks like this:

manifest: {
            generate: {
                options: {
                    basePath: "<%=pkg.folders.build + pkg.name + '-' + pkg.version%>",
                    network: ["*"],
                    fallback: [],
                    exclude: [],
                    preferOnline: false,
                    timestamp: true
                },
                src: [
                    "**/*"

                ],
                dest: "<%= pkg.folders.build + pkg.name + '-' + pkg.version%>/hwa-mobile.manifest"
            }
        },

I have tried different src-Strings but I can't get it to work that automatically ALL of the files (and only files) are included. I could manually exclude the folders but I don't want to change the buildfile every time something changes in folder structure.

Any hints?

Thanks!
Marco

I went into the same problem and had to add extension to filter

"js//*.js",
"css/
/*.css",

This is not convenient way when caching images though ^^

The only solution I got was to exclude the folders names manually like this:

**/*,
!css,
!js,
!images

Would like to know a solution which works automatically.

Having the same problem here.

I've forked the repo and made some changes so that the manifest task uses Grunt internal file mapping to build the cache file list. There is no need to include custom options, like basePath or exclude, since this is already handled by Grunt.

Now you can use cwd and filter options to build the src list, as described here. Note that you shouldn't use expand == true for this to work (contrary to what the docs say), since that will try to generate a manifest file for each src file found.

For example:

cwd: 'path/to/src/files',
src: ['**/*.html', '**/*.js'],
filter: 'isFile'

Will output only .html and .js files in path/to/src/files directory, and the file path won't include path/to/src/files.

@gunta, if you like this approach, I would be happy to send you a pull request.

I'm also having the exact same problem causing me to manually edit the manifest file whenever I build my application.

Excluding the folders manually works fine, but requires me to edit the Gruntfile each time I add a folder.

I'm in phase with honi. I tried that too but obviously, the plugin is not compatible with grunt files mechanism. That's too bad as this is really the core of grunt. Would be glad to be able to filter folders without having to explicitly write them.

@jan4dev if you want you can check my fork which uses grunt's internal file mapping.
@gunta any interest in me sending the pull request?

@heni, yes, it would be welcomed

All of my filenames have an extension and none of my folders have a period in them so this worked for me:

src: [ '**/*.*' ]

@honi Can you submit a PR? I would love to see this improvement integrated into the project.

@gunta Would you cut a new release if @honi made a PR?

I already did some time ago: #30