8
0

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 getWebpackConfig = require( '../dev/getwebpackconfig' );
  11. const getWebpackEs6Config = require( '../dev/getwebpackes6config' );
  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. console.log( 'Finished.' );
  27. } )
  28. .catch( ( err ) => {
  29. process.exitCode = -1;
  30. console.log( err );
  31. } );
  32. function runWebpack( webpackConfig, label ) {
  33. console.log( `Creating an ${ label } build...` );
  34. return new Promise( ( resolve, reject ) => {
  35. webpack( webpackConfig, ( err ) => {
  36. if ( err ) {
  37. return reject( err );
  38. }
  39. console.log( `The ${ label } build has been created.` );
  40. return resolve();
  41. } );
  42. } );
  43. }