【问题标题】:load html files with webpack into angular app using ngtemplate-loader使用 ngtemplate-loader 将带有 webpack 的 html 文件加载到 Angular 应用程序中
【发布时间】:2016-05-30 06:35:41
【问题描述】:

我正在尝试使用 ngtempalte-loader 将 html 部分加载到我的 Angular 应用程序中,但我不知道如何只包含某个文件夹。

假设我的树结构是这样的:

-root/
     -webpack.config.js
     -app/
        -templates/
           -template1/
               -file.html  
           -template2/

我在 webpack 的配置文件中使用了这个:

{
   test: /\.html$/,
   loader: 'ngtemplate?prefix=app/templates/!html'
}

我也试过

relativeTo=

但我没有运气......它总是会遍历我的所有应用程序并获取所有 html 文件。我只想让这个文件夹中的部分内容由 ngtemplate-loader 处理。 你们知道怎么做吗?

【问题讨论】:

  • 是否可以使用loaderexclude选项?

标签: javascript angularjs webpack angularjs-ng-template


【解决方案1】:

不确定这是否仍然相关,但您可以尝试一下。为此,您需要 Node 的“路径”模块。

{
  test: /\.html$/,
  loader: 'ngtemplate?relativeTo=' + (path.resolve(__dirname, './app/templates')) + '/!html'
}

【讨论】:

    猜你喜欢
    • 2019-07-28
    • 2022-07-02
    • 1970-01-01
    • 2019-09-12
    • 2021-03-18
    • 2016-08-23
    • 2019-03-05
    • 2016-10-02
    • 1970-01-01
    相关资源
    最近更新 更多