Geo
Geo

Reputation: 256

grunt-include-source multiple configurations

my problem is as following; I'm using grunt-include-source (https://www.npmjs.com/package/grunt-include-source) to include my scripts and css to my index.html, this is working fine but I can only specify one basepath, and i would like to setup this plugin for both dev and production. (im using the same folder structure so nothing will change in my index.html, the only difference is that in concatenate in my production)

 includeSource: {
  options: {
    basePath: 'dev'
  },
  myTarget: {
    files: {
      'dev/index.html': 'app/index.html'
    }
  }

},

Code above is working fine, now i want to have 2 different configuration, but something like this doesn't work when running the task includeSource:dev:

 includeSource: {
  dev: {
    options: {
      basePath: 'dev'
     },
     myTarget: {
      files: {
      'dev/index.html': 'app/index.html'
      }
     }
   },
   prod: {
    options: {
      basePath: 'prod'
     },
     myTarget: {
      files: {
      'prod/index.html': 'app/index.html'
      }
     }
   }
},

index.html:

 <!-- include: "type": "js", "files": "scripts/*.js" -->

Anyone could help me out how I would able to achieve this?

edit: Just to be a bit more clear, im running this script after my builds for either production or development is done, for both my prod/dev all scripts are stored in scripts/

Kind regards,

G

Upvotes: 1

Views: 314

Answers (1)

Jim Sangwine
Jim Sangwine

Reputation: 36

Just configure your task like this instead:

includeSource: {
  options: {
    basePath: 'dev/'
  },
  dev: {
    files: {
      'dev/index.html': 'app/index.html'
    }
  },
  prod: {
    options: {
      basePath: 'dist/'
    },
    files: {
      'dist/index.html': 'app/index.html'
    }
  }
},

Upvotes: 1

Related Questions