Is there a gulp module that can extract <script>
(or <style>
) tags into a separate file?
For example:
<html>
<body>
<style>
.my-style{
background:red;
}
</style>
<div class="my-style">
hello
</div>
<script>
var MyScript = function(){
console.log("hello");
}
</script>
</body>
</html>
<html>
<body>
<div class="my-style">
hello
</div>
</body>
</html>
.my-style{
background:red;
}
var MyScript = function(){
console.log("hello");
};
To extract inline scripts to external .js file you can use can use Cripser - https://www.npmjs.com/package/gulp-crisper
.pipe(crisper({
scriptInHead: true,
onlySplit: false
}))
While I couldn't find anything that extracts inline CSS to external file, you can at least minify the inline CSS using 'gulp-minify-inline' which is alternative option - https://www.npmjs.com/package/gulp-minify-inline
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With