I'm trying to generate a certain output for my locale files that is like _locales/[locale_shortcut]/[file].json
For this I'm using the file-loader plugin in webpack. According to the documentation, it's possible to use a function inside the option outputPath. There's however no documentation on how it should look like, and/or what the function should return. My best guess was that it returns a string just like the string value you would use directly in outputPath...
Using the following code for files that are named like [locale_shortcut].locale.json:
{
loader: "file-loader",
options: {
name: "[name].[ext]",
outputPath: (t: any) => {
return "_locales/" + t.replace(".locale.json") + "/";
},
},
},
I get the error:
EISDIR: illegal operation on a directory, open '/Users/[user]/projects/[project]/dist/_locales/en/'
Used dependencies:
- file-loader 2.0.0
- webpack 4.27.1
- typescript 3.1.1