grunt-manifest icon indicating copy to clipboard operation
grunt-manifest copied to clipboard

manifest contains folder names

Open marcorinck opened this issue 11 years ago • 11 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

marcorinck avatar May 13 '13 09:05 marcorinck

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 ^^

ertrzyiks avatar May 24 '13 13:05 ertrzyiks

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.

marcorinck avatar May 24 '13 17:05 marcorinck

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.

honi avatar May 29 '13 15:05 honi

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.

gillesdemey avatar Jun 07 '13 08:06 gillesdemey

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.

jeandat avatar Aug 08 '13 17:08 jeandat

@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?

honi avatar Aug 08 '13 18:08 honi

@heni, yes, it would be welcomed

gunta avatar Aug 12 '13 10:08 gunta

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

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

lread avatar Aug 27 '13 21:08 lread

@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?

ryandotsmith avatar Nov 27 '13 02:11 ryandotsmith

I already did some time ago: #30

honi avatar Nov 27 '13 12:11 honi

See #48.

gunta avatar Apr 28 '14 05:04 gunta