【问题标题】:Webpack file-loader using function in outputPath gives EISDIR illegal operation on a directory使用 outputPath 中的函数的 Webpack 文件加载器对目录进行 EISDIR 非法操作
【发布时间】:2019-05-20 18:30:20
【问题描述】:

我正在尝试为我的语言环境文件生成特定的输出,例如 _locales/[locale_shortcut]/[file].json

为此,我在 webpack 中使用了文件加载器插件。根据文档,可以在选项 outputPath 中使用函数。但是,没有关于它应该是什么样子和/或函数应该返回什么的文档。我最好的猜测是它返回一个字符串,就像您将直接在 outputPath 中使用的字符串值一样......

对名为 [locale_shortcut].locale.json 的文件使用以下代码:

{
    loader: "file-loader",
    options: {
        name: "[name].[ext]",
        outputPath: (t: any) => {
            return "_locales/" + t.replace(".locale.json") + "/";
        },
    },
},

我得到错误:

EISDIR:对目录的非法操作,打开'/Users/[user]/projects/[project]/dist/_locales/en/'

使用的依赖项:

  • 文件加载器 2.0.0
  • webpack 4.27.1
  • 打字稿 3.1.1

【问题讨论】:

    标签: typescript webpack webpack-file-loader


    【解决方案1】:

    好的...显然我必须在返回路径的末尾添加文件名才能使其工作:/

    【讨论】:

      猜你喜欢
      • 2021-07-13
      • 2020-03-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-25
      • 2018-12-20
      • 2021-06-20
      相关资源
      最近更新 更多