Skip to content Skip to sidebar Skip to footer

How Can I Run A Task In Grunt Using An Array Of Filenames Which Are Dynamically Generated?

I am fairly new to using Grunt but have a fairly good understanding of how tasks are installed and run. So far I am able to run everything as I want which includes minifying js, co

Solution 1:

You can use a variable to construct the config passed initConfig:

var deleteFilenames = ["foo", "bar", "baz"];
grunt.initConfig({
    clean: deleteFilenames
});

In the code above, the list is static but deleteFilenames could be constructed from an algorithm that computes file names.

Solution 2:

You can try using a wildcard token:

clean: ["file*"]

If you want something cleaner, you should include your Gruntfile.js or try to ouput your generated assets into a specific directory (such as dist/).

Post a Comment for "How Can I Run A Task In Grunt Using An Array Of Filenames Which Are Dynamically Generated?"