SPFx webpack loader 已定义,但仍然收到错误

SPFx webpack loader is defined, but am still receiving error

我正在尝试将 handlebars.js 合并到我的 SPFx 项目中。我一直在使用以下指南:https://n8d.at/how-to-use-handlebars-in-sharepoint-framework-projects-spfx/

但是,似乎没有应用 webpack 加载程序,因为我收到以下错误:

You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.

我的 gulpfile.js 包含以下代码:

const loaderConfig = {
  test: /\.hbs$/,
  use: {
    loader: "handlebars-loader",
  },
};

build.configureWebpack.mergeConfig({
  additionalConfiguration: (generatedConfiguration) => {
    generatedConfiguration.module.rules.push(loaderConfig);
    return generatedConfiguration;
  },
});

如果您有任何建议,请告诉我。

我意识到我的错误。我正在使用 spfx-fast-serve 库,它需要对 webpack 加载程序进行额外配置。看这里:https://github.com/s-KaiNet/spfx-fast-serve#webpack-extensibility