Socket
Socket
Sign inDemoInstall

stylus-loader

Package Overview
Dependencies
Maintainers
2
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stylus-loader - npm Package Compare versions

Comparing version 2.3.1 to 2.4.0

51

index.js

@@ -13,3 +13,2 @@ var loaderUtils = require('loader-utils');

var globalImportsCaches = {};
module.exports = function(source) {

@@ -24,4 +23,10 @@ var self = this;

var configKey = options.config || 'stylus';
var stylusOptions = this.options[configKey] || {};
var configKey, stylusOptions;
if (this.stylus) {
configKey = options.config || 'default';
stylusOptions = this.stylus[configKey] || {};
} else {
configKey = options.config || 'stylus';
stylusOptions = this.options[configKey] || {};
}
// Instead of assigning to options, we run them manually later so their side effects apply earlier for

@@ -175,1 +180,41 @@ // resolving paths.

};
var LoaderOptionsPlugin = require('webpack').LoaderOptionsPlugin;
// Webpack 2 plugin for setting options that'll be available to stylus-loader.
function OptionsPlugin(options) {
if (!LoaderOptionsPlugin) {
throw new Error(
'webpack.LoaderOptionPlugin is not available. A newer version of webpack is needed.'
);
}
var stylusOptions = {};
var test = options.test || /\.styl$/;
var include = options.include;
var exclude = options.exclude;
var loaderOptions = {
stylus: stylusOptions,
};
for (var key in options) {
if (['test', 'include', 'exclude'].indexOf(key) === -1) {
stylusOptions[key] = options[key];
}
}
if (test) {
loaderOptions.test = test;
}
if (include) {
loaderOptions.include = include;
}
if (exclude) {
loaderOptions.exclude = exclude;
}
this.plugin = new LoaderOptionsPlugin(loaderOptions);
};
module.exports.OptionsPlugin = OptionsPlugin;
OptionsPlugin.prototype.apply = function(compiler) {
this.plugin.apply(compiler);
};

4

package.json
{
"name": "stylus-loader",
"version": "2.3.1",
"version": "2.4.0",
"description": "Stylus loader for webpack",

@@ -14,3 +14,3 @@ "main": "index.js",

"test-one": "testem ci -l firefox",
"test-build": "webpack --config test/webpack.config.js --output-path test/tmp --output-file bundle.js"
"test-build": "webpack --config test/webpack.config.js --output-path=test/tmp --output-filename=bundle.js"
},

@@ -17,0 +17,0 @@ "author": "Kyle Robinson Young <kyle@dontkry.com> (http://dontkry.com)",

@@ -71,2 +71,86 @@ # stylus-loader

Multiple configs can be used by giving other configs different names and referring to the with the `config` query option.
```js
var stylus_plugin = require('stylus_plugin');
module: {
loaders: [
{
test: /\.other\.styl$/,
loader: 'style-loader!css-loader!stylus-loader?config=stylusOther'
}
]
},
stylusOther: {
use: [stylus_plugin()]
}
```
#### Webpack 2
Webpack 2 formalizes its options with a schema. Options can be provided to `stylus-loader` in the options field to `module.rules` or through LoaderOptionsPlugin or `stylus-loader`'s OptionsPlugin (a convenience wrapper around LoaderOptionsPlugin).
Config through module rules:
```js
module: {
rules: [
{
test: /\.styl$/,
use: [
'style-loader',
'css-loader',
{
loader: 'stylus-loader',
options: {
use: [stylus_plugin()],
},
},
],
}
],
},
```
Config through LoaderOptionsPlugin:
```js
module: {
rules: [
{
test: /\.styl$/,
loader: 'style-loader!css-loader!stylus-loader',
},
],
},
plugins: [
new webpack.LoaderOptionsPlugin({
test: /\.styl$/,
stylus: {
// You can have multiple stylus configs with other names and use them
// with `stylus-loader?config=otherConfig`.
default: {
use: [stylus_plugin()],
},
otherConfig: {
use: [other_plugin()],
},
},
}),
],
```
Config through `stylus-loader`'s OptionsPlugin (convenience wrapper for LoaderOptionsPlugin):
```js
plugins: [
new stylusLoader.OptionsPlugin({
default: {
use: [stylus_plugin()],
},
}),
],
```
#### Using nib with stylus

@@ -116,2 +200,3 @@

* Please see https://github.com/shama/stylus-loader/releases
* 2.4.0 - Add OptionsPlugin to help support webpack 2 (@mzgoddard)
* 2.3.1 - Fix typo in README (@stevewillard)

@@ -118,0 +203,0 @@ * 2.3.0 - Fix most use cases of relative path resolving (@mzgoddard), Add option to prefer a path resolver (webpack or stylus) (@mzgoddard)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc