The error you're encountering is related to how CSS is being processed by Laravel Mix 6, especially with the CKEditor 5 package. This issue often arises due to differences in how CSS and PostCSS are handled between different versions of Laravel Mix.
Here’s a step-by-step solution to resolve this issue:
-
Update Dependencies: Ensure that all your dependencies are up-to-date, especially
css-loader,postcss-loader, andstyle-loader. -
Install Required Packages: Make sure you have the necessary loaders installed. You can install them using npm or yarn:
npm install css-loader postcss-loader style-loader --save-dev -
Update
webpack.mix.jsConfiguration: Modify yourwebpack.mix.jsto handle CSS files correctly. You might need to add specific rules for handling CKEditor’s CSS files.
Here’s an example of how you can configure your webpack.mix.js:
const mix = require('laravel-mix');
mix.webpackConfig({
module: {
rules: [
{
test: /\.css$/,
use: [
'style-loader',
'css-loader',
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [
require('autoprefixer'),
],
},
},
},
],
},
],
},
});
mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css')
.version();
- Check for CKEditor Specific Configuration: CKEditor 5 might require specific configurations. Ensure that you are importing CKEditor’s CSS correctly in your JavaScript files. For example:
import ClassicEditor from '@ckeditor/ckeditor5-build-classic';
import '@ckeditor/ckeditor5-build-classic/build/translations/en';
import '@ckeditor/ckeditor5-build-classic/build/ckeditor.css';
ClassicEditor
.create(document.querySelector('#editor'))
.catch(error => {
console.error(error);
});
-
Run
npm run developmentAgain: After making these changes, try runningnpm run developmentagain to see if the issue is resolved.
npm run development
By following these steps, you should be able to resolve the CSS processing issues with Laravel Mix 6 and CKEditor 5. If the problem persists, consider checking the CKEditor 5 documentation or the Laravel Mix GitHub issues page for more specific solutions related to your setup.