gulpfile.js 4.2 KB

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