|
|
@@ -7,49 +7,45 @@
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
-const webpack = require( 'webpack' );
|
|
|
-const tasks = require( '@ckeditor/ckeditor5-dev-bundler-rollup' );
|
|
|
-
|
|
|
-const config = require( '../build-config' );
|
|
|
-const getWebpackConfig = require( '../dev/getwebpackconfig' );
|
|
|
-const getWebpackEs6Config = require( '../dev/getwebpackes6config' );
|
|
|
-
|
|
|
-console.log( 'Creating an entry file...' );
|
|
|
-
|
|
|
-tasks.createEntryFile( '.', {
|
|
|
- plugins: config.plugins,
|
|
|
- moduleName: config.moduleName,
|
|
|
- editor: config.editor,
|
|
|
- config: config.editorConfig,
|
|
|
+const path = require( 'path' );
|
|
|
+const tasks = require( '@ckeditor/ckeditor5-dev-bundler-webpack' );
|
|
|
+const { logger, bundler } = require( '@ckeditor/ckeditor5-dev-utils' );
|
|
|
+const getWebpackConfig = require( '@ckeditor/ckeditor5-dev-bundler-webpack/lib/utils/getwebpackconfig' );
|
|
|
+const getWebpackEs6Config = require( '@ckeditor/ckeditor5-dev-bundler-webpack/lib/utils/getwebpackes6config' );
|
|
|
+const buildConfig = require( '../build-config' );
|
|
|
+const log = logger();
|
|
|
+const entryPoint = 'ckeditor.js';
|
|
|
+
|
|
|
+log.info( 'Creating an entry file...' );
|
|
|
+
|
|
|
+bundler.createEntryFile( entryPoint, {
|
|
|
+ plugins: buildConfig.plugins,
|
|
|
+ moduleName: buildConfig.moduleName,
|
|
|
+ editor: buildConfig.editor,
|
|
|
+ config: buildConfig.editorConfig,
|
|
|
} );
|
|
|
|
|
|
-const webpackEs6Config = getWebpackEs6Config( config.destinationPath, config.moduleName );
|
|
|
-const webpackConfig = getWebpackConfig( config.destinationPath, config.moduleName );
|
|
|
+const cwd = path.join( __dirname, '..' );
|
|
|
+const webpackParams = {
|
|
|
+ cwd,
|
|
|
+ moduleName: buildConfig.moduleName,
|
|
|
+ entryPoint: path.join( cwd, entryPoint ),
|
|
|
+ destinationPath: path.join( cwd, buildConfig.destinationPath )
|
|
|
+};
|
|
|
+const webpackEs6Config = getWebpackEs6Config( webpackParams );
|
|
|
+const webpackConfig = getWebpackConfig( webpackParams );
|
|
|
+
|
|
|
+log.info( `Creating the "ES5" and "ES6" builds...` );
|
|
|
|
|
|
Promise.all( [
|
|
|
- runWebpack( webpackEs6Config, 'ES6' ),
|
|
|
- runWebpack( webpackConfig, 'ES5' ),
|
|
|
+ tasks.runWebpack( webpackEs6Config ).then( () => log.info( 'The "ES6" build has been created.' ) ),
|
|
|
+ tasks.runWebpack( webpackConfig ).then( () => log.info( 'The "ES5" build has been created.' ) )
|
|
|
] )
|
|
|
.then( () => {
|
|
|
- console.log( 'Finished.' );
|
|
|
+ log.info( 'Finished.' );
|
|
|
} )
|
|
|
.catch( ( err ) => {
|
|
|
process.exitCode = -1;
|
|
|
|
|
|
- console.log( err );
|
|
|
- } );
|
|
|
-
|
|
|
-function runWebpack( webpackConfig, label ) {
|
|
|
- console.log( `Creating an ${ label } build...` );
|
|
|
-
|
|
|
- return new Promise( ( resolve, reject ) => {
|
|
|
- webpack( webpackConfig, ( err ) => {
|
|
|
- if ( err ) {
|
|
|
- return reject( err );
|
|
|
- }
|
|
|
-
|
|
|
- console.log( `The ${ label } build has been created.` );
|
|
|
- return resolve();
|
|
|
- } );
|
|
|
+ log.error( err );
|
|
|
} );
|
|
|
-}
|