Skip to content

Instantly share code, notes, and snippets.

@johnkingzy
Created February 19, 2018 23:04
Show Gist options
  • Save johnkingzy/381fd28bca9e1ed3566dae75f614b7bf to your computer and use it in GitHub Desktop.
Save johnkingzy/381fd28bca9e1ed3566dae75f614b7bf to your computer and use it in GitHub Desktop.
Get the css and script tags that needs to be injected into the laravel view
var $ = cheerio.load(fs.readFileSync("./dist/index.html", "utf8"));
//get script tags that need to be injected into the laravel view
var scripts = $("script").map(function(i, el) {
return $("<div>").append($(el)).html();
}).toArray();
//get css tags that need to be injected into main laravel view
var styles = $("link").filter(function(i, el) {
return $(el).attr("href").indexOf("bundle.css") > -1;
}).map(function(i, el) {
return $("<div>").append($(el)).html();
}).toArray();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment