Open Rajesh-Thiyagarajan opened 4 years ago
Now I have done some modifications in some modifications in config-override.js
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path');
const TsConfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
const appName = 'cadence';
const { styles } = require('@ckeditor/ckeditor5-dev-utils');
const cssRegex = /\.css$/;
const cssModuleRegex = /\.module\.css$/;
module.exports = {
webpack: (config) => {
// Remove guard against importing modules outside of `src`.
// Needed for workspace projects.
config.resolve.plugins = config.resolve.plugins.filter(
(plugin) => !(plugin instanceof ModuleScopePlugin)
);
// Add support for importing workspace projects.
config.resolve.plugins.push(
new TsConfigPathsPlugin({
configFile: path.resolve(__dirname, 'tsconfig.json'),
extensions: ['.ts', '.tsx', '.js', '.jsx'],
mainFields: ['module', 'main'],
})
);
// Replace include option for babel loader with exclude
// so babel will handle workspace projects as well.
config.module.rules.forEach((r) => {
if (r.oneOf) {
const babelLoader = r.oneOf.find(
(rr) => rr.loader.indexOf('babel-loader') !== -1
);
babelLoader.exclude = /node_modules/;
delete babelLoader.include;
}
});
// Extract the oneOf array from the relevant webpack.module.rules object
let oneOf;
let ix;
ix = config.module.rules.findIndex((item) => {
return item.hasOwnProperty('oneOf');
});
oneOf = config.module.rules[ix].oneOf;
// Add the SVG and CSS loaders to the oneOf array
const additions = [
{
test: /ckeditor5-[^/\\]+[/\\]theme[/\\]icons[/\\][^/\\]+\.svg$/,
// test: /\.svg$/,
use: ['raw-loader'],
},
{
test: /ckeditor5-[^/\\]+[/\\]theme[/\\].+\.css$/,
use: [
{
loader: 'style-loader',
options: {
injectType: 'singletonStyleTag',
},
},
{
loader: 'postcss-loader',
options: styles.getPostCssConfig({
themeImporter: {
themePath: require.resolve('@ckeditor/ckeditor5-theme-lark'),
},
minify: true,
}),
},
],
},
];
additions.forEach((item, index) => {
oneOf.push(item);
});
// Modify cssRegex
let loader;
loader = oneOf.find((item) => {
if (item.test !== undefined)
return item.test.toString() === cssRegex.toString();
});
loader.exclude = [
cssModuleRegex,
/ckeditor5-[^/\\]+[/\\]theme[/\\].+\.css$/,
];
// Modify cssModuleRegex
loader = oneOf.find((item) => {
if (item.test !== undefined)
return item.test.toString() === cssModuleRegex.toString();
});
loader.exclude = [/ckeditor5-[^/\\]+[/\\]theme[/\\].+\.css$/];
// Modify file-loader
loader = oneOf.find((item) => {
if (item.loader !== undefined)
return (
item.loader.toString() === require.resolve('file-loader').toString()
);
});
loader.exclude = [
/ckeditor5-[^/\\]+[/\\]theme[/\\]icons[/\\][^/\\]+\.svg$/,
/ckeditor5-[^/\\]+[/\\]theme[/\\].+\.css$/,
// /\.svg$/,
];
return config;
},
paths: (paths) => {
// Rewrite dist folder to where Nx expects it to be.
paths.appBuild = path.resolve(__dirname, `../../dist/apps/${appName}`);
return paths;
},
jest: (config) => {
config.resolver = '@nrwl/jest/plugins/resolver';
return config;
},
};
if I comment below code the application get started. But ckeditor5 throwing error.
// Modify file-loader
loader.exclude = [
/ckeditor5-[^/\\]+[/\\]theme[/\\]icons[/\\][^/\\]+\.svg$/,
/ckeditor5-[^/\\]+[/\\]theme[/\\].+\.css$/,
// /\.svg$/,
];
Error
If i uncomment the code i am getting undefined error in the vscode terminal
Edit by @pomek: Formatting code style.
Hi Team Any update ?
@Rajesh-Thiyagarajan I'm facing the same issue, what I discover is that if I downgrade the version from react-scripts
to 4.0.3
, the CKEditor 5 compiles correctly. Not sure why yet, but looks like react-scripts uses webpack 5 and the exclude doesn't work as expected for multiple loaders.
Hi Team
Previously i am using craco config for ckeditor.
Edit by @pomek: Formatting code style.