8
0

gulpfile.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. DOCUMENTATION: {
  22. // Path to the built editors for samples.
  23. EDITORS_DIST: '.docs/assets/scripts/samples',
  24. // Glob pattern with samples.
  25. SAMPLES: 'docs/samples/**/*.@(md|html|js)',
  26. // Glob pattern with guides.
  27. GUIDES: 'docs/guides/**/*.md'
  28. },
  29. // Files ignored by jshint and jscs tasks. Files from .gitignore will be added automatically during tasks execution.
  30. IGNORED_FILES: [
  31. 'src/lib/**'
  32. ]
  33. };
  34. require( './dev/tasks/test/tasks' )( config ).register();
  35. // Lint tasks.
  36. const ckeditor5Lint = require( 'ckeditor5-dev-lint' )( config );
  37. gulp.task( 'lint', ckeditor5Lint.lint );
  38. gulp.task( 'lint-staged', ckeditor5Lint.lintStaged );
  39. gulp.task( 'default', [ 'compile' ] );
  40. gulp.task( 'pre-commit', [ 'lint-staged' ] );
  41. // Development environment tasks.
  42. const ckeditor5DevEnv = require( 'ckeditor5-dev-env' )( config );
  43. gulp.task( 'init', ckeditor5DevEnv.initRepository );
  44. gulp.task( 'create-package', ckeditor5DevEnv.createPackage );
  45. gulp.task( 'update', ckeditor5DevEnv.updateRepositories );
  46. gulp.task( 'pull', ckeditor5DevEnv.updateRepositories );
  47. gulp.task( 'status', ckeditor5DevEnv.checkStatus );
  48. gulp.task( 'st', ckeditor5DevEnv.checkStatus );
  49. gulp.task( 'relink', ckeditor5DevEnv.relink );
  50. gulp.task( 'install', ckeditor5DevEnv.installPackage );
  51. gulp.task( 'exec', ckeditor5DevEnv.execOnRepositories );
  52. // Bundling and building tasks.
  53. const ckeditor5DevBundle = require( 'ckeditor5-dev-bundler-rollup' )( config );
  54. gulp.task( 'bundle:clean', ckeditor5DevBundle.cleanFromConfig );
  55. gulp.task( 'bundle:minify:js', ckeditor5DevBundle.minify.jsFromConfig );
  56. gulp.task( 'bundle:minify:css', ckeditor5DevBundle.minify.cssFromConfig );
  57. gulp.task( 'build:generate',
  58. [
  59. 'bundle:clean',
  60. 'compile:js:esnext',
  61. 'compile:themes:esnext'
  62. ],
  63. ckeditor5DevBundle.generateFromConfig
  64. );
  65. gulp.task( 'build', ( callback ) => {
  66. runSequence( 'build:generate',
  67. [
  68. 'bundle:minify:js',
  69. 'bundle:minify:css'
  70. ],
  71. () => ckeditor5DevBundle.showSummaryFromConfig( callback )
  72. );
  73. } );
  74. // Compile tasks.
  75. const ckeditor5DevCompiler = require( 'ckeditor5-dev-compiler' )( config );
  76. const compiler = ckeditor5DevCompiler.compiler;
  77. gulp.task( 'compile', callback => {
  78. runSequence( 'compile:clean:all', 'compile:themes', 'compile:js', callback );
  79. } );
  80. // Clean tasks.
  81. gulp.task( 'compile:clean:all', () => compiler.clean.all() );
  82. gulp.task( 'compile:clean:themes', () => compiler.clean.themes() );
  83. gulp.task( 'compile:clean:js', () => compiler.clean.js() );
  84. gulp.task( 'compile:themes', ( callback ) => {
  85. runSequence( 'compile:clean:themes', 'compile:icons', 'compile:sass', callback );
  86. } );
  87. gulp.task( 'compile:sass', () => compiler.compile.sass() );
  88. gulp.task( 'compile:icons', () => compiler.compile.icons() );
  89. gulp.task( 'compile:js', [ 'compile:clean:js' ], () => compiler.compile.js() );
  90. // Tasks specific for preparing compiled output with unmodified source files. Uses by `gulp docs` or `gulp bundle`.
  91. gulp.task( 'compile:clean:js:esnext', () => compiler.clean.js( { formats: [ 'esnext' ] } ) );
  92. gulp.task( 'compile:clean:themes:esnext', () => compiler.clean.themes( { formats: [ 'esnext' ] } ) );
  93. gulp.task( 'compile:sass:esnext', () => compiler.compile.sass( { formats: [ 'esnext' ] } ) );
  94. gulp.task( 'compile:icons:esnext', () => compiler.compile.icons( { formats: [ 'esnext' ] } ) );
  95. gulp.task( 'compile:js:esnext', [ 'compile:clean:js:esnext' ], () => compiler.compile.js( { formats: [ 'esnext' ] } ) );
  96. gulp.task( 'compile:themes:esnext', ( callback ) => {
  97. runSequence( 'compile:clean:themes:esnext', 'compile:icons:esnext', 'compile:sass:esnext', callback );
  98. } );
  99. // Tasks specific for testing under node.
  100. gulp.task( 'compile:clean:js:cjs', () => compiler.clean.js( { formats: [ 'cjs' ] } ) );
  101. gulp.task( 'compile:js:cjs', [ 'compile:clean:js:cjs' ], () => compiler.compile.js( { formats: [ 'cjs' ] } ) );
  102. // Tasks specific for testing releases.
  103. gulp.task( 'test:samples:local', () => compiler.compile.tests.local() );
  104. gulp.task( 'test:samples:bundled', [ 'compile:samples' ], () => compiler.compile.tests.bundled() );
  105. gulp.task( 'test:samples', [ 'test:samples:local', 'test:samples:bundled' ] );
  106. // Tasks specific for building editors for testing releases.
  107. gulp.task( 'compile:samples:clean', ckeditor5DevBundle.cleanSamplesEditors );
  108. gulp.task( 'compile:samples',
  109. [
  110. 'compile:samples:clean',
  111. 'compile:js:esnext',
  112. 'compile:themes:esnext'
  113. ],
  114. ckeditor5DevBundle.buildEditorsForSamples
  115. );
  116. // Docs.
  117. const docsBuilder = ckeditor5DevCompiler.docs;
  118. gulp.task( 'docs', [ 'compile:js:esnext' ], docsBuilder.buildDocs );