gulpfile.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. MODULE_DIR: {
  12. amd: 'build/modules/amd',
  13. cjs: 'build/modules/cjs',
  14. esnext: 'build/modules/esnext'
  15. },
  16. DOCS_DIR: 'build/docs',
  17. BUNDLE_DIR: 'build/dist',
  18. WORKSPACE_DIR: '..',
  19. // Files ignored by jshint and jscs tasks. Files from .gitignore will be added automatically during tasks execution.
  20. IGNORED_FILES: [
  21. 'src/lib/**'
  22. ]
  23. };
  24. require( './dev/tasks/test/tasks' )( config ).register();
  25. // Lint tasks.
  26. const ckeditor5Lint = require( 'ckeditor5-dev-lint' )( config );
  27. gulp.task( 'lint', ckeditor5Lint.lint );
  28. gulp.task( 'lint-staged', ckeditor5Lint.lintStaged );
  29. gulp.task( 'default', [ 'compile' ] );
  30. gulp.task( 'pre-commit', [ 'lint-staged' ] );
  31. // Development environment tasks.
  32. const ckeditor5DevEnv = require( 'ckeditor5-dev-env' )( config );
  33. gulp.task( 'init', ckeditor5DevEnv.initRepository );
  34. gulp.task( 'create-package', ckeditor5DevEnv.createPackage );
  35. gulp.task( 'update', ckeditor5DevEnv.updateRepositories );
  36. gulp.task( 'pull', ckeditor5DevEnv.updateRepositories );
  37. gulp.task( 'status', ckeditor5DevEnv.checkStatus );
  38. gulp.task( 'st', ckeditor5DevEnv.checkStatus );
  39. gulp.task( 'relink', ckeditor5DevEnv.relink );
  40. gulp.task( 'install', ckeditor5DevEnv.installPackage );
  41. gulp.task( 'exec', ckeditor5DevEnv.execOnRepositories );
  42. // Bundling tasks.
  43. const ckeditor5DevBundle = require( 'ckeditor5-dev-bundler-rollup' )( config );
  44. gulp.task( 'bundle:clean', ckeditor5DevBundle.cleanFromConfig );
  45. gulp.task( 'bundle:generate',
  46. [
  47. 'bundle:clean',
  48. 'compile:js:esnext',
  49. 'compile:themes:esnext'
  50. ],
  51. ckeditor5DevBundle.generateFromConfig
  52. );
  53. gulp.task( 'bundle:minify:js', ckeditor5DevBundle.minify.jsFromConfig );
  54. gulp.task( 'bundle:minify:css', ckeditor5DevBundle.minify.cssFromConfig );
  55. gulp.task( 'bundle', ( callback ) => {
  56. runSequence( 'bundle:generate',
  57. [
  58. 'bundle:minify:js',
  59. 'bundle:minify:css'
  60. ],
  61. () => ckeditor5DevBundle.showSummaryFromConfig( callback )
  62. );
  63. } );
  64. // Compile tasks.
  65. const ckeditor5DevCompiler = require( 'ckeditor5-dev-compiler' )( config );
  66. const compiler = ckeditor5DevCompiler.compiler;
  67. gulp.task( 'compile', callback => {
  68. runSequence( 'compile:clean:all', 'compile:themes', 'compile:js', callback );
  69. } );
  70. // Clean tasks.
  71. gulp.task( 'compile:clean:all', () => compiler.clean.all() );
  72. gulp.task( 'compile:clean:themes', () => compiler.clean.themes() );
  73. gulp.task( 'compile:clean:js', () => compiler.clean.js() );
  74. gulp.task( 'compile:themes', ( callback ) => {
  75. runSequence( 'compile:clean:themes', 'compile:icons', 'compile:sass', callback );
  76. } );
  77. gulp.task( 'compile:sass', () => compiler.compile.sass() );
  78. gulp.task( 'compile:icons', () => compiler.compile.icons() );
  79. gulp.task( 'compile:js', [ 'compile:clean:js' ], () => compiler.compile.js() );
  80. // Tasks specific for preparing compiled output with unmodified source files. Uses by `gulp docs` or `gulp bundle`.
  81. gulp.task( 'compile:clean:js:esnext', () => compiler.clean.js( { formats: [ 'esnext' ] } ) );
  82. gulp.task( 'compile:clean:themes:esnext', () => compiler.clean.themes( { formats: [ 'esnext' ] } ) );
  83. gulp.task( 'compile:sass:esnext', () => compiler.compile.sass( { formats: [ 'esnext' ] } ) );
  84. gulp.task( 'compile:icons:esnext', () => compiler.compile.icons( { formats: [ 'esnext' ] } ) );
  85. gulp.task( 'compile:js:esnext', [ 'compile:clean:js:esnext' ], () => compiler.compile.js( { formats: [ 'esnext' ] } ) );
  86. gulp.task( 'compile:themes:esnext', ( callback ) => {
  87. runSequence( 'compile:clean:themes:esnext', 'compile:icons:esnext', 'compile:sass:esnext', callback );
  88. } );
  89. // Tasks specific for testing under node.
  90. gulp.task( 'compile:clean:js:cjs', () => compiler.clean.js( { formats: [ 'cjs' ] } ) );
  91. gulp.task( 'compile:js:cjs', [ 'compile:clean:js:cjs' ], () => compiler.compile.js( { formats: [ 'cjs' ] } ) );
  92. // Docs.
  93. const docsBuilder = ckeditor5DevCompiler.docs;
  94. gulp.task( 'docs', [ 'compile:js:esnext' ], docsBuilder.buildDocs );