Registry / web-framework / to-string-loader

to-string-loader

JSON →
library1.2.0jsnpmunverified

Webpack loader that converts CSS/SASS compiled output from an array to a plain string, useful for frameworks like Angular that require styles as strings. Current stable version: 1.2.0 (last released 2016-10-15). No recent updates; primarily used in legacy Angular 2 projects. Alternative: css-to-string-loader or raw-loader for similar functionality. Works with webpack 1-2; compatibility with webpack 3+ is unclear.

npm install to-string-loader
INSTALL
IMPORT
SIG · TO-STRING-LOADER
T
to-string-loader
web-frameworkjavascriptv1.2.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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
musl
node 18–226 runs
build_error
glibc
node 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');
Debug
Known issues
deprecatedPackage has not been updated since 2016; consider using css-to-string-loader or raw-loader.
fix
Replace with 'css-to-string-loader' or 'raw-loader' in modern webpack setups.
affects: >=1.0.0
gotchaLoader must be placed before css and sass in the loaders array, or the order is wrong.
fix
Ensure loaders order is: ['to-string', 'css', 'sass'].
affects: >=1.0.0
Errors
Common errors & fixes
Module parse failed: Unexpected character '@' (1:0)
Missing sass-loader before to-string-loader in loaders array.
fix
Add sass-loader to loaders: ['to-string', 'css', 'sass'].
Cannot find module 'to-string-loader'
Module not installed.
fix
Run: npm install --save-dev to-string-loader
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies
loader-utilsrequiredpeer dependency for webpack loader utils
webpackrequiredpeer dependency; loader is meant to be used with webpack
Agent activity
13 hits · last 30 days
node
10
Resources
to-string-loader — npm install to-string-loader · libregistry