build.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 webpack = require( 'webpack' );
  8. const tasks = require( '@ckeditor/ckeditor5-dev-bundler-rollup' );
  9. const config = require( '../build-config' );
  10. const getWebpackEs6Config = require( '../dev/webpackEs6Config' );
  11. const getWebpackConfig = require( '../dev/webpackConfig' );
  12. console.log( 'Creating an entry file...' );
  13. tasks.createEntryFile( '.', {
  14. plugins: config.plugins,
  15. moduleName: config.moduleName,
  16. editor: config.editor,
  17. config: config.editorConfig,
  18. } );
  19. const webpackEs6Config = getWebpackEs6Config( config.destinationPath, config.moduleName );
  20. const webpackConfig = getWebpackConfig( config.destinationPath, config.moduleName );
  21. Promise.all( [
  22. runWebpack( webpackEs6Config, 'ES6' ),
  23. runWebpack( webpackConfig, 'ES5' ),
  24. ] )
  25. .then( () => {
  26. } )
  27. .catch( ( err ) => {
  28. process.exitCode = -1;
  29. console.log( err );
  30. } );
  31. function runWebpack( webpackConfig, label ) {
  32. console.log( `Creating an ${ label } build...` );
  33. return new Promise( ( resolve, reject ) => {
  34. webpack( webpackConfig, ( err ) => {
  35. if ( err ) {
  36. return reject( err );
  37. }
  38. console.log( `The ${ label } build has been created.` );
  39. return resolve();
  40. } );
  41. } );
  42. }