Grunt-contrib-clean delete all folders / files except one folder and its contents

How would you cancel cleaning a specific folder using grunt-contrib-clean. Negating a match does not work.

clean: {
    plugins: [ 
        'app/plugins/myplugin',
        '!app/plugins/myplugin/assets'
    ]
}

I tried a couple of different negation patterns, for example:

'!app/plugins/myplugin/assets'
'!app/plugins/myplugin/assets/**'

as well as to pay attention to the positions in the array in case it matters. It seems that you cannot save the contents of the folder / contents in a clean form. The assets folder contains jQuery, AngularJS and built-in Bootstrap (SASS), which I do not want to store in copy / create, seems like a waste of time.

+4
source share
2 answers

, , , :

clean: {
    options: {
        'no-write': true
    },
    plugins: ['app/plugins/myplugin/**/*', '!app/plugins/myplugin/assets/**']
}

myplugin ( myplugin!), , .

, no-write: true , .

, !

+10

bower_components, require.js. gruntFile:

            /* all bower components except require */
            applicationDistHome + '/bower_components/**/*',
            '!' + applicationDistHome + '/bower_components/requirejs/**',
            applicationDistHome + '/bower_components/requirejs/*',
            '!' + applicationDistHome + '/bower_components/requirejs/require.js',
0

Source: https://habr.com/ru/post/1547120/


All Articles