Gruntfile.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. "use strict";
  2. const path = require('path');
  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. options: {
  23. configFile: 'build/conf/eslint.json',
  24. //rulesdir: ['build/rules'],
  25. },
  26. },
  27. examples: {
  28. src: [
  29. 'threejs/*.html',
  30. 'threejs/lessons/resources/*.js',
  31. '!threejs/lessons/resources/prettify.js',
  32. 'threejs/lessons/resources/*.html',
  33. ],
  34. options: {
  35. configFile: 'build/conf/eslint-examples.json',
  36. },
  37. },
  38. },
  39. copy: {
  40. main: {
  41. files: [
  42. { expand: false, src: '*', dest: 'out/', filter: noMdsNoFolders, },
  43. { expand: true, src: 'threejs/**', dest: 'out/', filter: noMds, },
  44. { expand: true, src: 'monaco-editor/**', dest: 'out/', },
  45. { expand: true, src: '3rdparty/**', dest: 'out/', },
  46. ],
  47. },
  48. },
  49. clean: [
  50. 'out/**/*',
  51. ],
  52. });
  53. grunt.registerTask('buildlessons', function() {
  54. var buildStuff = require('./build/js/build');
  55. var finish = this.async();
  56. buildStuff().then(function() {
  57. finish();
  58. }).done();
  59. });
  60. grunt.registerTask('build', ['clean', 'copy', 'buildlessons']);
  61. grunt.registerTask('default', ['eslint', 'build']);
  62. };