As I work on editing a configuration file, I'm encountering some issues where things aren't quite functioning as expected.
Below is the code snippet I am working with:
config.module.rules.unshift( {
test: "/ckeditor5-[^/\\]+[/\\]theme[/\\]icons[/\\][^/\\]+\.svg$/",
use: [ 'raw-loader' ]
}
);
fs.writeFileSync("C:\\temp\\config.txt", JSON.stringify(config) );
This results in a file that contains the following content...
{
"test": "/ckeditor5-[^/\\]+[/\\]theme[/\\]icons[/\\][^/\\]+.svg$/",
"use": [
"raw-loader"
]
},
However, the value for "test" appears to be incorrect. I want it to be set as follows:
{
test: /ckeditor5-[^/\\]+[/\\]theme[/\\]icons[/\\][^/\\]+\.svg$/,
use: [ 'raw-loader' ]
}
It's important to note that there are no quotes around the regular expression string in the desired output.
If I attempt to utilize the modified code like this:
config.module.rules.unshift( {
test: /ckeditor5-[^/\\]+[/\\]theme[/\\]icons[/\\][^/\\]+\.svg$/,
use: [ 'raw-loader' ]
}
);
fs.writeFileSync("C:\\temp\\config.txt", JSON.stringify(config) );
Here's the result I end up with instead:
{
"test": {},
"use": [ "raw-loader" ]
},
To achieve the correct outcome, I need the value of test to be:
/ckeditor5-[^/\\]+[/\\]theme[/\\]icons[/\\][^/\\]+\.svg$/