gulp-angular-resolve-relative-template-urls
Plugin searches for templateUrl: {relativeUrl}
and replaces it with templateUrl: {absoluteUrl}
.
Install
npm install --save-dev gulp-angular-resolve-relative-template-urls
Usage (Angular 1.x)
Given the following file structure
src+-hello-world |-hello-world-directivejs +-hello-world-templatehtml
hello-world-directive.js
:
angular;
hello-world-template.html
:
Hello world!
gulpfile.js
:
var gulp = ;var resolveRelativeTemplateUrls = ; gulp;
gulp-angular-resolve-relative-template-urls will generate the following file:
angular;
Note: call resolveRelativeTemplateUrls before source maps initialization.
API
resolveRelativeTemplateUrls(options)
options.basePath
Type: String
. The path against which the absolute path to the templates are resolved. Normally this is the path to the base folder from which your html files are served.
options.transformUrl
Type: Function
. Allows transforming the resolved absolute url. Useful for cases where files are written to a directory structure that is different from their source location. Example: function(templateUrl) { return '/static/' + templateUrl; }
options.skipFiles
Type: RegExp
or Function
. By default: do not skip any files. RegExp can test file name to skip template embedding, but this file will still be passed through the general gulp pipe and be visible for all of the following plugins. Example: function(file) {return file.path.endsWith('-skip-directive.js');}
options.skipTemplates
Type: RegExp
or Function
. By default: do not skip any templates. RegExp can test concrete templateUrl to skip it (like /\-large\.html$/
). Example: function(templatePath, fileContext) {return templatePath.endsWith('-large.html');}
options.skipErrors
Type: Boolean
. Default value: 'false'
should plugin brake on errors (file not found, error in minification) or skip errors (warn in logs) and go to next template
options.jsEncoding
Type: String
. Default value: 'utf-8'
js files encoding (angular directives)
License
This module is released under the MIT license.