You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

111 line
2.9 KiB

  1. /**
  2. * Copyright © Magento, Inc. All rights reserved.
  3. * See COPYING.txt for license details.
  4. */
  5. // For performance use one level down: 'name/{,*/}*.js'
  6. // If you want to recursively match all subfolders, use: 'name/**/*.js'
  7. module.exports = function (grunt) {
  8. 'use strict';
  9. var _ = require('underscore'),
  10. path = require('path'),
  11. filesRouter = require('./dev/tools/grunt/tools/files-router'),
  12. configDir = './dev/tools/grunt/configs',
  13. tasks = grunt.file.expand('./dev/tools/grunt/tasks/*'),
  14. themes;
  15. filesRouter.set('themes', 'dev/tools/grunt/configs/themes');
  16. themes = filesRouter.get('themes');
  17. tasks = _.map(tasks, function (task) {
  18. return task.replace('.js', '');
  19. });
  20. tasks.push('time-grunt');
  21. tasks.forEach(function (task) {
  22. require(task)(grunt);
  23. });
  24. require('load-grunt-config')(grunt, {
  25. configPath: path.join(__dirname, configDir),
  26. init: true,
  27. jitGrunt: {
  28. staticMappings: {
  29. usebanner: 'grunt-banner'
  30. }
  31. }
  32. });
  33. _.each({
  34. /**
  35. * Assembling tasks.
  36. * ToDo: define default tasks.
  37. */
  38. default: function () {
  39. grunt.log.subhead('I\'m default task and at the moment I\'m empty, sorry :/');
  40. },
  41. /**
  42. * Production preparation task.
  43. */
  44. prod: function (component) {
  45. var tasks = [
  46. 'less',
  47. 'cssmin',
  48. 'usebanner'
  49. ].map(function (task) {
  50. return task + ':' + component;
  51. });
  52. if (typeof component === 'undefined') {
  53. grunt.log.subhead('Tip: Please make sure that u specify prod subtask. By default prod task do nothing');
  54. } else {
  55. grunt.task.run(tasks);
  56. }
  57. },
  58. /**
  59. * Refresh themes.
  60. */
  61. refresh: function () {
  62. var tasks = [
  63. 'clean',
  64. 'exec:all'
  65. ];
  66. _.each(themes, function (theme, name) {
  67. tasks.push('less:' + name);
  68. });
  69. grunt.task.run(tasks);
  70. },
  71. /**
  72. * Documentation
  73. */
  74. documentation: [
  75. 'replace:documentation',
  76. 'less:documentation',
  77. 'styledocco:documentation',
  78. 'usebanner:documentationCss',
  79. 'usebanner:documentationLess',
  80. 'usebanner:documentationHtml',
  81. 'clean:var',
  82. 'clean:pub'
  83. ],
  84. 'legacy-build': [
  85. 'mage-minify:legacy'
  86. ],
  87. spec: function (theme) {
  88. var runner = require('./dev/tests/js/jasmine/spec_runner');
  89. runner.init(grunt, { theme: theme });
  90. grunt.task.run(runner.getTasks());
  91. }
  92. }, function (task, name) {
  93. grunt.registerTask(name, task);
  94. });
  95. };