filamentgroup / grunt-criticalcss

Grunt wrapper for criticalcss
MIT License
530 stars 27 forks source link

Specify project root in url ? #51

Closed ghost closed 1 year ago

ghost commented 6 years ago

New to all this and using it for a couple of projects. Not an issue but a question.

So that I don't need to change the project url for each project can I somehow specify the project root in the url string with a variable?

It would be great if there is a way to check for the location of the Gruntfile.js and then go up to the project root and put that variable inside the url string for the task.

Can that be done somehow? Below some pseudo code where you can see how I like to insert the project root.

index: {
  options: {
    url: "/",
    width: 1200,
    height: 900,
    outputfile: "resources/css/critical/critical-index.css",
    filename: "style.css"
  }
}
single: {
  options: {
    url: "/" + {projectRoot} + "/single/post/",
    width: 1200,
    height: 900,
    outputfile: "resources/css/critical/critical-single.css",
    filename: "style.css"
  }
},
"401": {
  options: {
    url: "/" + {projectRoot} + "/error-401/",
    width: 1200,
    height: 900,
    outputfile: "resources/css/critical/critical-401.css",
    filename: "style.css"
  }
},
"403": {
  options: {
    url: "/" + {projectRoot} + "/error-403/",
    width: 1200,
    height: 900,
    outputfile: "resources/css/critical/critical-403.css",
    filename: "style.css"
  }
},

My local projects are set up so that I have localhost/{ProjectName}/index.html etc. in the url and not via domain itself, though that should not matter for getting the project root I assume.

Thank you for any help with this.