All Projects → dferber90 → fake-style-loader

dferber90 / fake-style-loader

Licence: other
[DEPRECATED] Like style-loader, but can be used on server

Programming Languages

javascript
184084 projects - #8 most used programming language

fake-style-loader

This works similar to style-loader, except it can be used on the server.

Deprecation Notice

css-loader supports most of what this module enables out of the box by invoking css-loader/locals instead of style-loader!css-loader as stated in the css-loader documentation.

More information in #3. Kudos to @chibicode for finding this out.

The only part not supported using css-loader/locals is the special source property fake-style-loader adds. This is an edge case and it may be possible to work around this using extract-text-webpack-plugin.

Usage

// in webpack config loaders, for server bundle
{ test: /\.css$/, loader: 'fake-style!css?modules' },

// in webpack config loaders, for client bundle (unrelated to this plugin)
{ test: /\.css$/, loader: 'style!css?modules' },
var styles = require('./some-file.css')

console.log(styles)
// returns
// {
//   heading: '.XYZABC123',
//   ...
//   source: '.heading { color: blue; }'
// }

The classnames are returned, just like when using the style-loader and the css-loader in modules mode. As an added bonus the returned object contains a source property which contains the CSS source code after it has went through css-loader. As an example, this css source can be inlined into the HTML response on the server.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].