karma-ng-html2js-preprocessor icon indicating copy to clipboard operation
karma-ng-html2js-preprocessor copied to clipboard

html2js-preprocessor adding relative template url

Open indranilatwork opened this issue 10 years ago • 2 comments

My project folder is at var/www/apps/angular/myproject

And the templates are in the templates folder under myproject.

So the template url is specified in the directive is "/template/directive.html"

So in the karma config I've written

ngHtml2JsPreprocessor: { stripPrefix: 'var/www/apps/angular/myproject', moduleName: "my.templates" },

And this config works. But I don't want to specify the full path to the project in the config because for some other environment this might change. But "myproject" folder will be always there.

So I tried with stripPrefix: '*/myproject', But it didn't work. Please tell me how I can fix it?

indranilatwork avatar Nov 28 '15 14:11 indranilatwork

One way I got around this was to use Nodes path module.

I set this before the Karma configuration

var path = require('path');

Then set the basepath as

basePath: path.resolve(),

Might help until relative paths are available.

nicfusc avatar Jan 14 '16 12:01 nicfusc

I set my base path to the root of the folder, './', and it fixed this issue.

NickMurphy avatar Nov 24 '17 16:11 NickMurphy