gulp-inline-ng2-template icon indicating copy to clipboard operation
gulp-inline-ng2-template copied to clipboard

Resolve relative path, not only aside files

Open damoncasale opened this issue 8 years ago • 8 comments

Templates are supposed to be declared relative to the individual folders that the template files are in, whereas this plugin expects them to be declared relative to the root module. That's wrong, and should be fixed.

And yes, UseRelativePaths is set to false and I'm still seeing that behavior. I looked at the code and there's no possible way for it to properly detect the paths of templates in subfolders, relative to their components.

In getFilePath, absPath simply cannot determine the correct relative path. file.path is always the path of app.module.ts, rather than the path of the related component.

damoncasale avatar Sep 06 '16 22:09 damoncasale

If you thing something is wrong you are very much welcome to send a PR.

ludohenin avatar Sep 08 '16 06:09 ludohenin

Yes, this is definitely an issue when using relative html/css paths in components.

For instance, my component looks like this:

// app/my-component/my.component.ts
@Component( {
    selector: 'my-component',
    moduleId: __moduleName,
    templateUrl: './my.component.html',
    styleUrls: [ './my.component.css' ]
} )
export class MyComponent {}

Here, gulp-inline-ng2-template looks for ./my.component.html instead of ./app/my-component/my.component.html

gregjacobs avatar Sep 28 '16 17:09 gregjacobs

Err, never mind, totally missed the useRelativePaths option. Works as expected!

gregjacobs avatar Sep 28 '16 17:09 gregjacobs

That's odd. useRelativePaths didn't work for me, setting it to either true or false.

damoncasale avatar Sep 28 '16 17:09 damoncasale

This solved the problem for me too! It seems to me that it would be more intuitive if useRelativePaths was true by default, but now I know to set it when I use this plugin.

gforceg avatar Oct 24 '16 18:10 gforceg

How to deal with systemjs and module.id property in angular component? Setting UseRelativePaths doesn't help - base: "/appTS", target: "es5", UseRelativePaths: true,. The plugin does not look at sub-folders and try to find all templates in the base folder.

unsafePtr avatar Nov 28 '16 14:11 unsafePtr

@unsafePtr Make sure useRelativePaths has a lowercase u

gregjacobs avatar Nov 29 '16 01:11 gregjacobs

@gregjacobs Thanks. It was source mistake where is written with big U. May be you can help cause it is a very big headache for me.

unsafePtr avatar Nov 29 '16 12:11 unsafePtr