Created
February 19, 2018 23:04
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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