Kaynağa Gözat

Updated build webpack config for PostCSS.

Aleksander Nowodzinski 8 yıl önce
ebeveyn
işleme
9e99becd1f

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
packages/ckeditor5-build-classic/build/ckeditor.js


Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
packages/ckeditor5-build-classic/build/ckeditor.js.map


+ 0 - 35
packages/ckeditor5-build-classic/postcss.config.js

@@ -1,35 +0,0 @@
-/**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-/* eslint-env node */
-
-const path = require( 'path' );
-const postCssImport = require( 'postcss-import' );
-const postCssNext = require( 'postcss-cssnext' );
-const cssnano = require( 'cssnano' );
-const themeImporter = require( './themeimporter' );
-
-module.exports = {
-	plugins: [
-		postCssImport(),
-		themeImporter( {
-			themePath: path.resolve( __dirname, 'node_modules/@ckeditor/ckeditor5-theme-lark' )
-		} ),
-		postCssNext( {
-			// features: {
-				// customProperties: {
-				// 	variables: {
-				// 		fg: "red",
-				// 		bg: "green",
-				// 		foo: "#456"
-				// 	}
-				// }
-			// }
-		} ),
-		// cssnano( { autoprefixer: false } )
-	]
-};

+ 0 - 77
packages/ckeditor5-build-classic/themeimporter.js

@@ -1,77 +0,0 @@
-/**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-/* eslint-env node */
-
-const fs = require( 'fs' );
-const path = require( 'path' );
-const postcss = require( 'postcss' );
-const postCssImport = require( 'postcss-import' );
-
-module.exports = postcss.plugin( 'postcss-ckeditor-theme-importer', options => {
-	const themeName = options.themePath.split( '/' ).slice( -1 );
-	console.log( `Using theme "${ themeName }".` );
-
-	return root => {
-		const fileName = path.basename( root.source.input.file );
-		const packageName = getPackageName( root.source.input.file );
-		const relativeFilePath = path.relative( __dirname, root.source.input.file );
-		const themeFile = path.resolve( __dirname, options.themePath, 'theme', packageName, fileName );
-
-		if ( fs.existsSync( themeFile ) ) {
-			console.log( `Found a corresponding theme file for ${ relativeFilePath }. Including.` );
-
-			return new Promise( resolve => {
-				fs.readFile( themeFile, 'utf8', ( err, data ) => {
-					const processor = postcss( {
-						plugins: [
-							postCssImport()
-						]
-					} );
-
-					return processor.process( data, { from: themeFile } )
-						.then( result => {
-							root.append( result.css );
-							root.append( '\n' );
-
-							resolve();
-						} );
-				} );
-			} );
-		} else {
-			console.log( `Theme file for ${ relativeFilePath } not found in theme "${ themeName }".` );
-		}
-	};
-} );
-
-function getPackageName( path ) {
-	const match = path.match( /ckeditor5-[^/]+/ );
-
-	if ( match ) {
-		return match[ 0 ];
-	} else {
-		return null;
-	}
-}
-
-// function CKThemeLogger() {
-// 	return ( root ) => {
-// 		root.prepend( `/* ${ root.source.input.file } */` );
-// 	};
-// }
-
-// const CKRaiseSpecificity = postcss.plugin( 'postcss-ck-specificity', ( opts ) => {
-// 	opts = opts || {};
-
-// 	return ( root, result ) => {
-// 		root.walkRules( rule => {
-// 			if ( rule.selector.match( /^\.ck-/g ) ) {
-// 				rule.selector = 'body ' + rule.selector;
-// 			}
-// 		} );
-// 	};
-// } );

+ 5 - 5
packages/ckeditor5-build-classic/webpack.config.js

@@ -10,6 +10,7 @@
 const path = require( 'path' );
 const webpack = require( 'webpack' );
 const { bundler } = require( '@ckeditor/ckeditor5-dev-utils' );
+const getPostCssConfig = require( '@ckeditor/ckeditor5-dev-utils' ).themes.getPostCssConfig;
 const CKEditorWebpackPlugin = require( '@ckeditor/ckeditor5-dev-webpack-plugin' );
 const BabiliPlugin = require( 'babel-minify-webpack-plugin' );
 const buildConfig = require( './build-config' );
@@ -57,11 +58,10 @@ module.exports = {
 					},
 					{
 						loader: 'postcss-loader',
-						options: {
-							config: {
-								path: path.resolve( __dirname, 'postcss.config.js' )
-							}
-						}
+						options: getPostCssConfig( {
+							themePath: path.resolve( __dirname, 'node_modules/@ckeditor/ckeditor5-theme-lark' ),
+							minify: true
+						} )
 					},
 				]
 			}