polyfill.js 1.3 KB

1234567891011121314151617181920212223242526272829
  1. /**
  2. * `tasks/register/polyfill.js`
  3. *
  4. * ---------------------------------------------------------------
  5. *
  6. * For more information see:
  7. * https://sailsjs.com/anatomy/tasks/register/polyfill.js
  8. *
  9. */
  10. module.exports = function(grunt) {
  11. grunt.registerTask('polyfill:prod', 'Add the polyfill file to the top of the list of files to concatenate', ()=>{
  12. grunt.config.set('concat.js.src', [require('sails-hook-grunt/accessible/babel-polyfill')].concat(grunt.config.get('concat.js.src')));
  13. });
  14. grunt.registerTask('polyfill:dev', 'Add the polyfill file to the top of the list of files to copy and link', ()=>{
  15. grunt.config.set('copy.dev.files', grunt.config.get('copy.dev.files').concat({
  16. expand: true,
  17. cwd: require('path').dirname(require('sails-hook-grunt/accessible/babel-polyfill')),
  18. src: require('path').basename(require('sails-hook-grunt/accessible/babel-polyfill')),
  19. dest: '.tmp/public/polyfill'
  20. }));
  21. var devLinkFiles = grunt.config.get('sails-linker.devJs.files');
  22. grunt.config.set('sails-linker.devJs.files', Object.keys(devLinkFiles).reduce((linkerConfigSoFar, glob)=>{
  23. linkerConfigSoFar[glob] = ['.tmp/public/polyfill/polyfill.min.js'].concat(devLinkFiles[glob]);
  24. return linkerConfigSoFar;
  25. }, {}));
  26. });
  27. };