Last active
December 3, 2021 15:31
-
-
Save Ghostbird/cea7619a4995a0997f2622548c2b0a72 to your computer and use it in GitHub Desktop.
Node script to load a CSS file as if it is a JS file. Workaround for Angular 13 extractCss deprecation.
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
#!/usr/bin/env node | |
process.stdout.write( | |
`const styleElement = document.createElement('style');styleElement.appendChild(document.createTextNode(\``, | |
() => process.stdin.pipe(process.stdout, { end: false }) | |
); | |
process.stdin.on('end', () => | |
process.stdout.write( | |
`\`));document.getElementsByTagName('head')[0].appendChild(styleElement);\n`, | |
() => process.stdout.end() | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use, call it like this:
Keep in mind that you must trust your
styles.css
file! Otherwise you open yourself up to malicious javascript injection. This script was written specifically to repackage thestyles.css
file created by the Angular compiler.