ngtemplate-loader icon indicating copy to clipboard operation
ngtemplate-loader copied to clipboard

relativeTo parameter is not working

Open Airboy opened this issue 7 years ago • 1 comments

Hi,

I'm a bit confused by this loader, I'll try to set up a very straightforward config where all my HTML files are located into a templates folder (see the folder structure below). Thus if I have correctly understood the way this module works, I defined the following config:

webpack.config.js

{
     test: /\.html$/,
     use: [
         {
             loader: 'ngtemplate-loader?relativeTo=' + (path.resolve(__dirname, '../templates')),
        }
    ]
}

Folder structure

    .
    ├── app
    ├── templates
    └── ...

When I try to require my templates/root.html from my angular entry point app/main.js with the following command:

const rootTpl = require('root.html');

I get the following error:

ERROR in ./app/main.js
Module not found: Error: Can't resolve 'root.html' in '[__dirname]/app'

I don't understand why it tries to resolve the path of my root.html from /app instead of /templates. Any idea about what is wrong with my configuration? Maybe I'm missing something obvious.

I'm using angular 1.5.11, webpack 3.10.0 and ngtemplate-loader 2.0.1.

Airboy avatar Jan 17 '18 15:01 Airboy

require('./root.html') maybe?

stevenvachon avatar Oct 16 '18 17:10 stevenvachon