Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including gulp-cordova-xml with all npm packages installed. Try it out:

var gulpCordovaXml = require("gulp-cordova-xml")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

gulp-cordova-xml v1.0.1

Adds raw xml to your cordova config file.

gulp-cordova-xml Build Status

Adds raw xml tags to your config.xml

Installation

npm install --save-dev gulp-cordova-xml

Usage

The following example will add two access tags to the config.xml file.

const gulp = require('gulp');
const create = require('gulp-cordova-create');
const xml = require('gulp-cordova-xml');

gulp.task('build', () => {
    return gulp.src('dist')
        .pipe(create())
        .pipe(xml('<access origin="http://www.google.com" />'))
        .pipe(xml('<access origin="http://www.github.com" />'));
});

It's not possible to add two tags in one plugin call. If you want to do this, you should pass an array of tags as parameter.

const gulp = require('gulp');
const create = require('gulp-cordova-create');
const xml = require('gulp-cordova-xml');

gulp.task('build', () => {
    return gulp.src('dist')
        .pipe(create())
        .pipe(xml([
                    '<access origin="http://www.google.com" />',
                    '<access origin="http://www.github.com" />'
                  ]));
});

Notice that this second method is faster then the first method. The reason for this is that everytime the plugin is called, the config.xml file is parsed all over again. Because you only call the plugin once with the array-method, the config file will only be parsed once instace of twice.

Please not that this is not the best way for adding access tags. Use gulp-cordova-access for that.

API

xml(tags)

tags

Required
Type: string|string[]

A raw xml tag or an array of raw xml tags.

Related

See gulp-cordova for the full list of available packages.

License

MIT © Sam Verschueren

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free