Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pgutkowski/template-url-loader
https://github.com/pgutkowski/template-url-loader
Last synced: 21 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/pgutkowski/template-url-loader
- Owner: pgutkowski
- Created: 2016-04-22T11:44:39.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-04-25T19:49:13.000Z (over 8 years ago)
- Last Synced: 2024-11-16T08:19:17.492Z (about 1 month ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# template-url-loader for webpack
Replaces every "templateUrl: 'url'," in code with "template: require(./url)". It's allows You to bundle external directives and components which are not webpack ready (like [AngularStrap](http://mgcrea.github.io/angular-strap/))
## Usage
[Documentation: Using loaders](http://webpack.github.io/docs/using-loaders.html)
## Examples
To use template-url-loader You can either declare it in webpack.config.js:
````js
loaders: [
{ test: /\.js$/, loader: "template-url-loader" },
]},
````
or in import statement:
````js
import package from 'template-url-loader!path/package.js';
//package contains Angular module declaring templateUrl.
````###Passing path prefix
Paths declared as templateUrl may differ from relative path from declaring module to template file. To create proper require statement, You can pass path prefix as argument, as follows:
````js
require("template-url-loader?../prefix/path!path/package.js");
//string between '?' and '!' ('../prefix/path') is prefix added to every replaced templateUrl in file.
````You can find working example [here](https://github.com/PawelGutkowski/openmrs-contrib-uicommons/blob/master/angular/openmrs-conceptAutocomplete/openmrs-conceptAutocomplete.component.js)
## License
MIT (http://www.opensource.org/licenses/mit-license.php)