Gruntfile.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*eslint-env node*/
  2. 'use strict';
  3. const fs = require('fs');
  4. module.exports = function(grunt) {
  5. require('load-grunt-tasks')(grunt);
  6. const s_ignoreRE = /\.(md|py|sh|enc)$/i;
  7. function noMds(filename) {
  8. return !s_ignoreRE.test(filename);
  9. }
  10. function notFolder(filename) {
  11. return !fs.statSync(filename).isDirectory();
  12. }
  13. function noMdsNoFolders(filename) {
  14. return noMds(filename) && notFolder(filename);
  15. }
  16. grunt.initConfig({
  17. eslint: {
  18. lib: {
  19. src: [
  20. 'threejs/resources/*.js',
  21. ],
  22. },
  23. support: {
  24. src: [
  25. 'Gruntfile.js',
  26. 'build/js/build.js',
  27. ],
  28. },
  29. examples: {
  30. src: [
  31. 'threejs/*.html',
  32. 'threejs/lessons/resources/*.js',
  33. '!threejs/lessons/resources/prettify.js',
  34. 'threejs/lessons/resources/*.html',
  35. ],
  36. },
  37. },
  38. copy: {
  39. main: {
  40. files: [
  41. { expand: false, src: '*', dest: 'out/', filter: noMdsNoFolders, },
  42. { expand: true, src: 'threejs/**', dest: 'out/', filter: noMds, },
  43. { expand: true, src: 'monaco-editor/**', dest: 'out/', },
  44. { expand: true, src: '3rdparty/**', dest: 'out/', },
  45. ],
  46. },
  47. },
  48. clean: [
  49. 'out/**/*',
  50. ],
  51. });
  52. grunt.registerTask('buildlessons', function() {
  53. const buildStuff = require('./build/js/build');
  54. const finish = this.async();
  55. buildStuff().then(function() {
  56. finish();
  57. }).done();
  58. });
  59. grunt.registerTask('build', ['clean', 'copy', 'buildlessons']);
  60. grunt.registerTask('default', ['eslint', 'build']);
  61. };