Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
default
✓ import toString from 'to-string-loader'
✗ import { toString } from 'to-string-loader'
Loader is typically not imported directly; it's referenced in webpack config as 'to-string'.
require (runtime usage)
✓ let output = require('to-string!css!sass!./my.scss');
✗ let output = require('to-string!./my.scss');
Use inline syntax with preceding loaders like css and sass.
webpack config loader
✓ loaders: ['to-string', 'css', 'sass']
✗ loaders: ['to-string-loader', 'css', 'sass']
In webpack config, omit the '-loader' suffix; webpack resolves it automatically.
Configures webpack to convert SASS output to string using to-string-loader.
// webpack.config.js
module.exports = {
module: {
loaders: [
{
test: /\.scss$/,
loaders: ['to-string', 'css', 'sass']
}
]
}
};
// In your code (e.g., Angular component)
@Component({
styles: [require('./my.scss')] // now returns a string
})
export class MyComponent {}
// Or inline:
let style = require('to-string!css!sass!./my.scss');
Errors
Common errors & fixes
Module parse failed: Unexpected character '@' (1:0)
Missing sass-loader before to-string-loader in loaders array.
fixAdd sass-loader to loaders: ['to-string', 'css', 'sass'].
Cannot find module 'to-string-loader'
Module not installed.
fixRun: npm install --save-dev to-string-loader
Audit
Dependencies
loader-utilsrequiredpeer dependency for webpack loader utils
webpackrequiredpeer dependency; loader is meant to be used with webpack