I am in the process of setting up a webpack configuration for CKEditor 5 to create a custom build. Below is my webpack.mix.js file:
const mix = require('laravel-mix');
require('laravel-mix-purgecss');
const { styles } = require( '@ckeditor/ckeditor5-dev-utils' );
const webpack = require('webpack');
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Laravel applications. By default, we are compiling the CSS
| file for the application as well as bundling up all the JS files.
|
*/
mix.js('resources/js/app.js', 'public/js').vue()
.postCss('resources/css/app.css', 'public/css', [
require('postcss-import'),
require('tailwindcss'),
require('autoprefixer'),
])
.webpackConfig(require('./webpack.config'));
const CKEditorWebpackPlugin = require('@ckeditor/ckeditor5-dev-webpack-plugin')
const CKEStyles = require('@ckeditor/ckeditor5-dev-utils').styles
const CKERegex = {
svg: /ckeditor5-[^/\\]+[/\\]theme[/\\]icons[/\\][^/\\]+\.svg$/,
css: /ckeditor5-[^/\\]+[/\\]theme[/\\].+\.css/
}
Mix.listen('configReady', webpackConfig => {
const rules = webpackConfig.module.rules
const targetSVG = /(\.(png|jpe?g|gif|webp)$|^((?!font).)*\.svg$)/
const targetCSS = /\.css$/
// exclude CKE regex from mix's default rules
// if there's a better way to loop/change this, open to suggestions
for (const rule of rules) {
if (rule.test.toString() === targetSVG.toString()) {
rule.exclude = CKERegex.svg
} else if (rule.test.toString() === targetCSS.toString()) {
rule.exclude = CKERegex.css
}
}
});
mix.webpackConfig({
module: {
rules: [
{
test: /ckeditor5-[^/\\]+[/\\]theme[/\\]icons[/\\][^/\\]+\.svg$/,
use: [ 'raw-loader' ]
},
{
test: /ckeditor5-[^/\\]+[/\\]theme[/\\].+\.scss$/,
use: [
{
loader: 'style-loader',
options: {
injectType: 'singletonStyleTag',
attributes: {
'data-cke': true
}
}
},
'css-loader',
{
loader: 'postcss-loader',
options: {
postcssOptions: styles.getPostCssConfig( {
themeImporter: {
themePath: require.resolve( '@ckeditor/ckeditor5-theme-lark' )
},
minify: true
} )
}
}
]
}
]
},
}
);
However, despite my efforts, I am encountering the following error:
CKEditorError: svg is null Read more: is null
XML parsing error: incorrect Line 1, character 1:
I am attempting to integrate a custom CKEditor 5 build into my Vue.js and Laravel application.