Skip to content

Commit b1bd0b2

Browse files
committed
fix error when outPath is not set & resourcePath is provided as absolute path
1 parent aa44926 commit b1bd0b2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ export default class I18nextPlugin {
217217

218218
return Promise.all(_.map(this.option.namespaces, async ns => {
219219
const resourcePath = getPath(resourceTemplate, undefined, ns);
220-
const outPath = getPath(this.option.outPath, lng, ns);
220+
const outPath = getPath(this.outPath, lng, ns);
221221

222222
try {
223223
const v = await readFile(resourcePath);
@@ -240,6 +240,13 @@ export default class I18nextPlugin {
240240
}
241241
}
242242

243+
protected get outPath() {
244+
if (path.isAbsolute(this.option.outPath)) {
245+
return path.relative(this.context, this.option.outPath);
246+
}
247+
return this.option.outPath;
248+
}
249+
243250
protected async onAfterEmit(compilation: wp.Compilation, callback: (err?: Error) => void) {
244251
const remains: _.Dictionary<_.Dictionary<any>> = _.fromPairs(_.map(
245252
this.option.languages, lng => [

0 commit comments

Comments
 (0)