浏览代码

Introduced "@ckeditor/ckeditor5-dev-bundler-webpack" for creating the builds.

Kamil Piechaczek 8 年之前
父节点
当前提交
428268fe12

+ 31 - 35
packages/ckeditor5-build-classic/bin/build.js

@@ -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 );
 	} );
-}

文件差异内容过多而无法显示
+ 222 - 222
packages/ckeditor5-build-classic/build/ckeditor.es6.js


文件差异内容过多而无法显示
+ 1 - 1
packages/ckeditor5-build-classic/build/ckeditor.es6.js.map


文件差异内容过多而无法显示
+ 50 - 50
packages/ckeditor5-build-classic/build/ckeditor.js


文件差异内容过多而无法显示
+ 0 - 1
packages/ckeditor5-build-classic/build/ckeditor.js.map


+ 0 - 31
packages/ckeditor5-build-classic/dev/getwebpackconfig.js

@@ -1,31 +0,0 @@
-/**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-const webpack = require( 'webpack' );
-const getWebpackEs6Config = require( './getwebpackes6config' );
-
-module.exports = function getWebpackConfig( destinationPath, moduleName ) {
-	const config = getWebpackEs6Config( destinationPath, moduleName );
-
-	config.output.filename = 'ckeditor.js';
-
-	config.plugins = [
-		new webpack.optimize.UglifyJsPlugin()
-	];
-
-	config.module.rules.push( {
-		test: /\.js$/,
-		loader: 'babel-loader',
-		options: {
-			presets: [
-				'es2015'
-			]
-		}
-	} );
-
-	return config;
-};

+ 0 - 52
packages/ckeditor5-build-classic/dev/getwebpackes6config.js

@@ -1,52 +0,0 @@
-/**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-const path = require( 'path' );
-const webpack = require( 'webpack' );
-const BabiliPlugin = require( 'babili-webpack-plugin' );
-
-module.exports = function getWebpackConfig( destinationPath, moduleName ) {
-	return {
-		devtool: 'cheap-source-map',
-
-		entry: [
-			path.resolve( __dirname, '..', 'ckeditor.js' )
-		],
-
-		output: {
-			path: path.resolve( __dirname, '..', destinationPath ),
-			filename: 'ckeditor.es6.js',
-			libraryTarget: 'umd',
-			library: moduleName
-		},
-
-		plugins: [
-			new BabiliPlugin()
-		],
-
-		module: {
-			rules: [
-				{
-					// test: **/ckeditor5-*/theme/icons/*.svg
-					test: /ckeditor5-[^/]+\/theme\/icons\/[^/]+\.svg$/,
-					use: [ 'raw-loader' ]
-				},
-				{
-					// test: **/ckeditor5-*/theme/**/*.scss
-					test: /\.scss$/,
-					use: [ 'style-loader', 'css-loader', 'sass-loader' ]
-				}
-			]
-		},
-
-		resolveLoader: {
-			modules: [
-				'node_modules'
-			]
-		}
-	};
-};

+ 2 - 8
packages/ckeditor5-build-classic/package.json

@@ -4,16 +4,10 @@
   "main": "./build/ckeditor.es6.js",
   "dependencies": {},
   "devDependencies": {
-    "@ckeditor/ckeditor5-dev-bundler-rollup": "^5.0.7",
     "@ckeditor/ckeditor5-dev-utils": "^2.4.2",
+    "@ckeditor/ckeditor5-dev-bundler-webpack": "^1.0.0",
     "@ckeditor/ckeditor5-editor-classic": "*",
-    "@ckeditor/ckeditor5-presets": "*",
-    "babel-core": "^6.24.0",
-    "babel-loader": "^6.4.0",
-    "babel-preset-env": "^1.2.2",
-    "babel-preset-es2015": "^6.24.0",
-    "babili-webpack-plugin": "0.0.11",
-    "webpack": "^2.2.1"
+    "@ckeditor/ckeditor5-presets": "*"
   },
   "scripts": {
     "build": "node ./bin/build.js"