Grunt plugin which generates a crossdomain.xml file


Grunt plugin for generating crossdomain.xml.

You can grab more info about the crossdomain.xml file on the dedicated Adobe page.

Install npm package:

npm install grunt-crossdomain-xml

Add this line to your project's Gruntfile.js:


crossdomainxml is a multitask, so you can use crossdomainxml:dist and register some other tasks than "dist":

        crossdomainxml: {
            dist: {
                dest: 'src/',
                siteControl: 'master-only',
                allowAccessFrom: [
                        'domain': '*'
                        'domain': '*',
                        'secure': false,
                        'toPorts': ['9865', '9000:9100']
                allowHttpRequestHeadersFrom: [
                        'domain': '*'
                        'domain': '*',
                        'headers': ['SOAPAction', 'AnotherHeader'],
                        'secure': false

The above configuration should give you the following src/crossdomain.xml file:

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "">
    <site-control permitted-cross-domain-policies="master-only"/>
    <allow-access-from domain="*"/>
    <allow-access-from domain="*" secure="false" to-ports="9865,9000:9100"/>
    <allow-http-request-headers-from domain="*"/>
    <allow-http-request-headers-from domain="*" secure="false" headers="SOAPAction,AnotherHeader"/>
  • dest: String (./ by default)

    Path where robots.txt will be created

  • siteControl: Object (none by default)

    Can be none, master-only, by-content-type, by-ftp-filename, all

  • allowAccessFrom: Object (none by default)

    Hash of your access policy. You can provide as many hashes with domains as you want. Note that you can give an array of values for toPorts in order to allow multiple ports or port ranges. You can also pass a full comma-separated list of ports as a string. Here, you would enter 'toPorts': '9865,9000:9100

There is a build process (which involves Grunt) for this Grunt task. Basically, the process will check the code with JSHint and JSCS, and execute some tests.

You can launch this process with the grunt command:


Or if you just want to test (and not check code):

grunt test

This plugin for Grunt is released under the MIT License.