Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
css-to-string-loader
Advanced tools
Webpack loader to convert the output of the css-loader back to a string
A simple webpack loader to convert the output of the css-loader back to a string.
This is quite useful for situations where you want webpack to process all of your @import
and url()
statements in your stylesheets but still receive the styles in string format for further use in your code base.
npm install css-to-string-loader --save-dev
var styleString = require('css-to-string-loader!css-loader!./file.css');
{
...
module: {
loaders: [
{ test: /\.css$/, loader: 'css-to-string-loader!css-loader' }
]
}
}
This loader was originally created to be used with Angular 2 component styling. The styles array in the component decorator expects an array of strings and the css-loader outputs its own custom array object. A common solution was to use the raw-loader to take CSS files or the output of sass-loader and convert it to a string. These solutions did not allow for processing of nested resources such as images and font files with minification, cache-busting hashes, or inlining with the url-loader.
// Angular 2 Component
@Component({
...
styles: [require('./component.scss')],
...
})
// Webpack Config
{
module: {
loaders: [
{ test: /\.scss/, loader: 'css-to-string-loader!css-loader!sass-loader'}
]
}
}
It is also possible to achieve the same result as this loader by calling the custom .toString()
method implementation on the returned value of the css-loader. In fact, that is really all this loader does for you. However, by adding this into your loader chain, you don't have to worry about having to write it every time.
FAQs
Webpack loader to convert the output of the css-loader back to a string
The npm package css-to-string-loader receives a total of 3,486 weekly downloads. As such, css-to-string-loader popularity was classified as popular.
We found that css-to-string-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.