@ckeditor/ckeditor5-dev-utils
Version:
Utils for CKEditor 5 development tools packages.
49 lines (42 loc) • 1.36 kB
JavaScript
/**
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md.
*/
;
/* eslint-env node */
/**
* Returns a PostCSS configuration to build the editor styles (e.g. used by postcss-loader).
*
* @param {Object} options
* @param {Boolean} options.sourceMap When true, an inline source map will be built into the output CSS.
* @param {Boolean} options.minify When true, the output CSS will be minified.
* @param {ThemeImporterOptions} options.themeImporter Configuration of the theme-importer PostCSS plugin.
* See the plugin to learn more.
* @returns {Object} A PostCSS configuration object, e.g. to be used by the postcss-loader.
*/
module.exports = function getPostCssConfig( options = {} ) {
const config = {
plugins: [
require( 'postcss-import' )(),
require( './themeimporter' )( options.themeImporter ),
require( 'postcss-mixins' )(),
require( 'postcss-nesting' )( {
// https://github.com/ckeditor/ckeditor5/issues/11730
noIsPseudoSelector: true,
edition: '2021'
} ),
require( './themelogger' )()
]
};
if ( options.sourceMap ) {
config.sourceMap = 'inline';
}
if ( options.minify ) {
config.plugins.push( require( 'cssnano' )( {
preset: 'default',
autoprefixer: false,
reduceIdents: false
} ) );
}
return config;
};