build.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/usr/bin/env node
  2. /**
  3. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  4. * For licensing, see LICENSE.md.
  5. */
  6. 'use strict';
  7. const path = require( 'path' );
  8. const tasks = require( '@ckeditor/ckeditor5-dev-bundler-webpack' );
  9. const { logger, bundler } = require( '@ckeditor/ckeditor5-dev-utils' );
  10. const getWebpackConfig = require( '@ckeditor/ckeditor5-dev-bundler-webpack/lib/utils/getwebpackconfig' );
  11. const getWebpackES6Config = require( '@ckeditor/ckeditor5-dev-bundler-webpack/lib/utils/getwebpackes6config' );
  12. const buildConfig = require( '../build-config' );
  13. const log = logger();
  14. const entryPoint = 'ckeditor.js';
  15. log.info( 'Creating an entry file...' );
  16. bundler.createEntryFile( entryPoint, {
  17. plugins: buildConfig.plugins,
  18. moduleName: buildConfig.moduleName,
  19. editor: buildConfig.editor,
  20. config: buildConfig.editorConfig,
  21. } );
  22. const cwd = path.join( __dirname, '..' );
  23. const webpackParams = {
  24. cwd,
  25. moduleName: buildConfig.moduleName,
  26. entryPoint: path.join( cwd, entryPoint ),
  27. destinationPath: path.join( cwd, buildConfig.destinationPath )
  28. };
  29. const webpackES6Config = getWebpackES6Config( webpackParams );
  30. const webpackConfig = getWebpackConfig( webpackParams );
  31. log.info( `Creating the "ES5" and "ES6" builds...` );
  32. Promise.all( [
  33. tasks.runWebpack( webpackES6Config ).then( () => log.info( 'The "ES6" build has been created.' ) ),
  34. tasks.runWebpack( webpackConfig ).then( () => log.info( 'The "ES5" build has been created.' ) )
  35. ] )
  36. .then( () => {
  37. log.info( 'Finished.' );
  38. } )
  39. .catch( ( err ) => {
  40. process.exitCode = -1;
  41. log.error( err );
  42. } );