gulpfile.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* jshint browser: false, node: true, strict: true */
  6. 'use strict';
  7. const gulp = require( 'gulp' );
  8. const runSequence = require( 'run-sequence' );
  9. const config = {
  10. ROOT_DIR: '.',
  11. BUILD_DIR: 'build',
  12. BUNDLE_DIR: 'bundle',
  13. WORKSPACE_DIR: '..',
  14. // Files ignored by jshint and jscs tasks. Files from .gitignore will be added automatically during tasks execution.
  15. IGNORED_FILES: [
  16. 'src/lib/**'
  17. ]
  18. };
  19. require( './dev/tasks/test/tasks' )( config ).register();
  20. // Lint tasks.
  21. const ckeditor5Lint = require( 'ckeditor5-dev-lint' )( config );
  22. gulp.task( 'lint', ckeditor5Lint.lint );
  23. gulp.task( 'lint-staged', ckeditor5Lint.lintStaged );
  24. gulp.task( 'default', [ 'build' ] );
  25. gulp.task( 'pre-commit', [ 'lint-staged' ] );
  26. // Development environment tasks.
  27. const ckeditor5DevEnv = require( 'ckeditor5-dev-env' )( config );
  28. gulp.task( 'init', ckeditor5DevEnv.initRepository );
  29. gulp.task( 'create-package', ckeditor5DevEnv.createPackage );
  30. gulp.task( 'update', ckeditor5DevEnv.updateRepositories );
  31. gulp.task( 'pull', ckeditor5DevEnv.updateRepositories );
  32. gulp.task( 'status', ckeditor5DevEnv.checkStatus );
  33. gulp.task( 'st', ckeditor5DevEnv.checkStatus );
  34. gulp.task( 'relink', ckeditor5DevEnv.relink );
  35. gulp.task( 'install', ckeditor5DevEnv.installPackage );
  36. gulp.task( 'exec', ckeditor5DevEnv.execOnRepositories );
  37. // Bundling tasks.
  38. const ckeditor5DevBundle = require( 'ckeditor5-dev-bundler-rollup' )( config );
  39. gulp.task( 'bundle:clean', ckeditor5DevBundle.cleanFromConfig );
  40. gulp.task( 'bundle:generate',
  41. [
  42. 'bundle:clean',
  43. 'build:js:esnext',
  44. 'build:themes:esnext'
  45. ],
  46. ckeditor5DevBundle.generateFromConfig
  47. );
  48. gulp.task( 'bundle:minify:js', ckeditor5DevBundle.minify.jsFromConfig );
  49. gulp.task( 'bundle:minify:css', ckeditor5DevBundle.minify.cssFromConfig );
  50. gulp.task( 'bundle', ( callback ) => {
  51. runSequence( 'bundle:generate',
  52. [
  53. 'bundle:minify:js',
  54. 'bundle:minify:css'
  55. ],
  56. () => ckeditor5DevBundle.showSummaryFromConfig( callback )
  57. );
  58. } );
  59. // Build tasks.
  60. const ckeditor5DevBuilder = require( 'ckeditor5-dev-builder' )( config );
  61. const builder = ckeditor5DevBuilder.builder;
  62. gulp.task( 'build', callback => {
  63. runSequence( 'build:clean:all', 'build:themes', 'build:js', callback );
  64. } );
  65. gulp.task( 'build:clean:all', builder.clean.all );
  66. gulp.task( 'build:clean:themes', builder.clean.themes );
  67. gulp.task( 'build:clean:js', () => builder.clean.js() );
  68. gulp.task( 'build:themes', ( callback ) => {
  69. runSequence( 'build:clean:themes', 'build:icons', 'build:sass', callback );
  70. } );
  71. gulp.task( 'build:sass', () => builder.build.sass() );
  72. gulp.task( 'build:icons', () => builder.build.icons() );
  73. gulp.task( 'build:js', [ 'build:clean:js' ], () => builder.build.js() );
  74. // Tasks specific for preparing build with unmodified source files. Uses by `gulp docs` or `gulp bundle`.
  75. gulp.task( 'build:clean:js:esnext', () => builder.clean.js( { formats: [ 'esnext' ] } ) );
  76. gulp.task( 'build:clean:themes:esnext', () => builder.clean.themes( { formats: [ 'esnext' ] } ) );
  77. gulp.task( 'build:sass:esnext', () => builder.build.sass( { formats: [ 'esnext' ] } ) );
  78. gulp.task( 'build:icons:esnext', () => builder.build.icons( { formats: [ 'esnext' ] } ) );
  79. gulp.task( 'build:js:esnext', [ 'build:clean:js:esnext' ], () => builder.build.js( { formats: [ 'esnext' ] } ) );
  80. gulp.task( 'build:themes:esnext', ( callback ) => {
  81. runSequence( 'build:clean:themes:esnext', 'build:icons:esnext', 'build:sass:esnext', callback );
  82. } );
  83. // Tasks specific for testing under node.
  84. gulp.task( 'build:clean:js:cjs', () => builder.clean.js( { formats: [ 'cjs' ] } ) );
  85. gulp.task( 'build:js:cjs', [ 'build:clean:js:cjs' ], () => builder.build.js( { formats: [ 'cjs' ] } ) );
  86. // Docs.
  87. const docsBuilder = ckeditor5DevBuilder.docs;
  88. gulp.task( 'docs', [ 'build:js:esnext' ], docsBuilder.buildDocs );