Gruntfile.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. ],
  31. options: {
  32. configFile: 'build/conf/eslint-examples.json',
  33. },
  34. },
  35. },
  36. copy: {
  37. main: {
  38. files: [
  39. { expand: false, src: '*', dest: 'out/', filter: noMdsNoFolders, },
  40. { expand: true, src: 'threejs/**', dest: 'out/', filter: noMds, },
  41. { expand: true, src: 'monaco-editor/**', dest: 'out/', },
  42. { expand: true, src: '3rdparty/**', dest: 'out/', },
  43. ],
  44. },
  45. },
  46. clean: [
  47. 'out/**/*',
  48. ],
  49. });
  50. grunt.registerTask('buildlessons', function() {
  51. var buildStuff = require('./build/js/build');
  52. var finish = this.async();
  53. buildStuff().then(function() {
  54. finish();
  55. }).done();
  56. });
  57. grunt.registerTask('build', ['clean', 'copy', 'buildlessons']);
  58. grunt.registerTask('default', ['eslint', 'build']);
  59. };
粤ICP备19079148号