Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Angular templatecache webpack loader

> This repo adds the

Puts HTML files to Angular $templateCache.


Expand Down Expand Up @@ -46,7 +48,20 @@ index.html
}
```

3. You can also use context in webpack to pass correct template url. See [Context example](https://github.com/EJIqpEP/angular-templatecache-loader/tree/master/examples/context)
3. relativeTo - remove a string from the path

relativeTo is used to strip a matching prefix from the path of the input html file.

```javascript
{
test: /\.html$/,
loader: "angular-templatecache-loader?relativeTo=/public/"
}
```

The above will remove the "/public/" from the generated templateUrl path.

4. You can also use context in webpack to pass correct template url. See [Context example](https://github.com/EJIqpEP/angular-templatecache-loader/tree/master/examples/context)

```javascript
var app = path.join(__dirname, 'app');
Expand Down
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = function (source) {
var outputPath;
var outputSource = '';

var relativeTo = query.relativeTo || '';
var prefix = query.prefix || '';
var module = query.module ? query.module : 'ng';

Expand All @@ -25,9 +26,9 @@ module.exports = function (source) {
root = root.replace(/\\/g, separator);

if (prefix) {
outputPath = prefix + resourcePath.replace(root, '');
outputPath = prefix + resourcePath.replace(root, '').replace(relativeTo, '');
} else {
outputPath = resourcePath.replace(root, '').slice(1);
outputPath = resourcePath.replace(root, '').slice(1).replace(relativeTo, '');
}

this.cacheable && this.cacheable();
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-templatecache-loader",
"version": "0.2.0",
"name": "angular-templatecache-loader-2",
"version": "0.3.4",
"description": "Webpack angular templateCache loader",
"main": "index.js",
"scripts": {
Expand All @@ -14,9 +14,9 @@
"loader"
],
"author": {
"name": "Alexander Kochergin",
"email": "ejiqpep@gmail.com",
"url": "https://github.com/EJIqpEP"
"name": "Paul Bastowski",
"email": "pbastowski@gmail.com",
"url": "https://github.com/pbastowski"
},
"license": "MIT",
"devDependencies": {
Expand All @@ -33,10 +33,10 @@
},
"repository": {
"type": "git",
"url": "https://github.com/EJIqpEP/angular-templatecache-webpack-loader"
"url": "https://github.com/pbastowski/angular-templatecache-loader"
},
"bugs": {
"url": "https://github.com/EJIqpEP/angular-templatecache-webpack-loader/issues"
"url": "https://github.com/pbastowski/angular-templatecache-loader/issues"
},
"homepage": "https://github.com/EJIqpEP/angular-templatecache-webpack-loader"
"homepage": "https://github.com/pbastowski/angular-templatecache-loader"
}