load html files with webpack into angular app using ngtemplate-loader

776 views Asked by At

I'm trying to load html partials in to my angular app using ngtempalte-loader I can't figure out how to only include a certain folder.

Lets say my tree structure is as so:

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

And I'm using this in the config file for webpack:

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

I also tried with

relativeTo=

But i have no luck... It always goes through all my app and picks up all the html files. I would like to just have the partials in this folder being dealt with ngtemplate-loader. You guys know how?

1

There are 1 answers

0
Kayes On

Not sure if this is still relevant, but you can give this a try. You require Node's 'path' module for this.

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