Search code examples
javascriptgulpdelfile-globs

Match minified JavaScript files and html files using globs


I'm trying to delete all files except for my minified JavaScript files, all which have the .min suffix, and all .html files. This is what I have currently:

del([
   'build/app/**/*.!(html|min.js)'
]);

This ends up deleting all .js files, including the minified ones, but keeps the .html files. How can I modify this so it deletes all files except for the JavaScript files with the .min suffix and the .html files?


Solution

  • Exclude the .html and .min.js files separately:

    del([
     'build/app/**/*.*',
     '!build/app/**/*.html',
     '!build/app/**/*.min.js'
    ]);