gruntjs / grunt-contrib-copy

Copy files and folders.
http://gruntjs.com/
MIT License
727 stars 194 forks source link

Replace not working with multiple files. #299

Open ZeroThe2nd opened 6 years ago

ZeroThe2nd commented 6 years ago

Having my copy object written for multiple files as in the docs, but adding the process option, does not work as it should. The files get copied, but not modified. When not using the files but defining a single file as per the docs, the copy and replace works, but for one file only.

I'm running the folloing:

Copy section from gruntfile.js

copy   : {
    main : {
        files : [
            {                src     : 'assets/js/app.js',
                dest    : 'dist/assets/js/app.build.js',
                options : {
                    process : function(content, srcpath) {
                        return content.replace(/(\.css')/g, '.min.css\'');
                    },
                },
            },
            {
                src     : 'index.html',
                dest    : 'dist/index.html',
                options : {
                    process : function(content, srcpath) {
                        return content.replace('assets/js/app.js', 'assets/js/app.min.js');
                    },
                },
            },
            {
                src  : 'assets/js/Helper.js',
                dest : 'dist/assets/js/Helper.build.js',
            },
            {
                expand : true,
                src    : [
                    '/assets/audio/**',
                    '/assets/icons/**',
                    '/assets/images/**',
                ],
                dest   : 'dist/assets',
                filter : 'isFile',
            },
        ],
    },
},