8
0

gulpfile.js 4.2 KB

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