Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/viiees/babel-plugin-ng-template-url-absolutify
https://github.com/viiees/babel-plugin-ng-template-url-absolutify
angularjs babel babel-plugin browserify gulp gulp-plugin
Last synced: 21 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/viiees/babel-plugin-ng-template-url-absolutify
- Owner: ViieeS
- License: mit
- Created: 2018-03-14T09:16:14.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-09-14T13:14:04.000Z (over 6 years ago)
- Last Synced: 2024-12-15T06:48:17.932Z (26 days ago)
- Topics: angularjs, babel, babel-plugin, browserify, gulp, gulp-plugin
- Language: JavaScript
- Size: 8.79 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# babel-plugin-ng-template-url-absolutify
Transform AngularJS templateUrl relative paths to absolute URLs.
```
$ npm install babel-plugin-ng-template-url-absolutify --save-dev
```## Usage
Use in either package.json or with gulp:
### a) Package.json
Add the transform in package.json:
#### Babel
```json
{
"babel": {
"presets": ["env"],
"extensions": [".es6"],
"plugins": [
["babel-plugin-ng-template-url-absolutify", {"baseDir": "./app", "baseUrl": "http://mysite.com/"}]
]
}
}
```#### Browserify with Babelify
```json
{
"browserify": {
"transform": [
["babelify", {
"presets": ["env"],
"extensions": [".es6"],
"plugins": [
["babel-plugin-ng-template-url-absolutify", {"baseDir": "./app", "baseUrl": "http://mysite.com/"}]
]
}
]
]
}
}
```### b) With Gulp + Browserify with Babelify
Add it to the babelify object and specify a `baseDir` and `baseUrl`.
```js
var gulp = require('gulp'),
browserify = require('browserify');gulp.task('scripts', function() {
return browserify('./src/app.js')
.transform("babelify", {
presets: ["env"],
extensions: [".es6"],
plugins: [[
"babel-plugin-ng-template-url-absolutify",
{baseDir: "./app", baseUrl: "http://mysite.com/"}
]]
})
.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest('./dist'));
});
```## Example
#### Before:
```js
'use strict';angular.module('app').component('cmp', {
controller: function () {/* ... */},
templateUrl: './template.html'
});
```#### After:
```js
'use strict';angular.module('app').component('cmp', {
controller: function () {/* ... */},
templateUrl: 'http://mysite.com/app/template.html'
});
```## License
[MIT License](http://en.wikipedia.org/wiki/MIT_License)