简体   繁体   中英

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

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'
    }
  }
},

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM