I am trying to replace some placeholders in different files when copying. My grunt file works fine, but it adds the ability to make replacements to the process, it just doesn't work. Below is the relevant section of my grunt file:
grunt.initConfig({ copy: { js: { files: [{ expand: true, cwd: 'src/wp-content/themes/pilau-starter/', src: ['**/*.js'], dest: 'public/wp-content/themes/pilau-starter/' }], options: { process: function ( content ) { console.log( content ); content = content.replace( /pilauBreakpointLarge/g, breakpoints.large ); content = content.replace( /pilauBreakpointMedium/g, breakpoints.medium ); return content; } } }, } });
The paths can be understood in the context of the GitHub code: https://github.com/pilau/starter (the shared directory is not tied to the repo, because this is the starting topic). These paths are variables in my source Gruntfile and work fine in all other tasks.
All varnas are configured OK. I turned on console.log( content ) to check if this function of the process really works - it seems this is not so, so I assume this is the basic syntax.
There is an answer ( https://stackoverflow.com/a/165168/ ) that seems to address this, but as far as I can tell, this way of doing it is just bad JS syntax - not sure how it is indicated as correctly.
--verbose output to start the copy task:
Running "copy:js" (copy) task Verifying property copy.js exists in config...OK Files: src/wp-content/themes/pilau-starter/js/admin.js -> public/wp-content/themes/pilau-starter/js/admin.js Files: src/wp-content/themes/pilau-starter/js/flickity.js -> public/wp-content/themes/pilau-starter/js/flickity.js Files: src/wp-content/themes/pilau-starter/js/global.js -> public/wp-content/themes/pilau-starter/js/global.js Files: src/wp-content/themes/pilau-starter/js/modernizr.js -> public/wp-content/themes/pilau-starter/js/modernizr.js Files: src/wp-content/themes/pilau-starter/js/picturefill.js -> public/wp-content/themes/pilau-starter/js/picturefill.js Files: src/wp-content/themes/pilau-starter/js/respond.js -> public/wp-content/themes/pilau-starter/js/respond.js Options: processContent=false, processContentExclude=[], process=undefined Options: processContent=false, processContentExclude=[], process=undefined Copying src/wp-content/themes/pilau-starter/js/admin.js -> public/wp-content/themes/pilau-starter/js/admin.js Reading src/wp-content/themes/pilau-starter/js/admin.js...OK Writing public/wp-content/themes/pilau-starter/js/admin.js...OK
source share