Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_.each(options, function(value, key) {
if (key === 'urlfunc') {
// Custom name of function for embedding images as Data URI
if (_.isString(value)) {
s.define(value, stylus.url());
} else {
s.define(value.name, stylus.url({
limit: value.limit !== null ? value.limit : 30000,
paths: value.paths ? value.paths : []
}));
}
} else if (key === 'use') {
value.forEach(function(func) {
if (_.isFunction(func)) {
s.use(func());
}
});
} else if (key === 'define') {
for (var defineName in value) {
s.define(defineName, value[defineName], shouldUseRawDefine(defineName));
}
exports.process = function(input, callback) {
var interleave = this,
opts = this.opts.stylus || {},
plugins = opts.plugins || {};
try {
var stylus = require('stylus'),
renderer = stylus(input.content, { filename: input.file });
// if we have plugins use them
for (var key in plugins) {
renderer.use(plugins[key]());
}
if (opts.urlEmbed) {
renderer.define('url', stylus.url());
}
renderer.render(function(err, css) {
if (err) {
callback('could not render: ' + err.message);
}
else {
callback(null, {
file: (input.file || '').replace(/\.styl$/, '.css'),
content: css
});
}
});
}
catch (e) {
callback(new Error('stylus not installed, run \'npm install stylus\' to add the plugin'));
fs.readFile('./src/themes/snow/snow.styl', function(err, data) {
var s = stylus(data.toString());
s.include('./src/themes/snow');
s.define('url', stylus.url());
s.render(function(err, css) {
res.write(css);
res.end();
})
});
});
function buildMinifiedCss (string) {
let cssString = ''
stylus(string)
.set('compress', true)
.use(nib())
.import('nib')
.define('url', stylus.url())
.render((err, css) => {
if (err) throw err
cssString = css.replace(/\n/g, '')
})
return cssString
}
{
test: /\.styl$/,
loaders: [
'style',
'css',
'postcss',
'stylus',
],
},
],
},
stylus: {
define: {
DEBUG: true,
embedurl: require('stylus').url(),
},
},
postcss: function() {
return [
autoprefixer({
browsers: ['last 2 versions', 'not ie < 11', 'not ie_mob < 11'],
}),
];
},
};
return function(style) {
style.define('url', stylus.url());
};
};
break;
case 'include':
includes.push(v);
break;
case 'import':
imports.push(v);
break;
case 'url':
let obj;
if (typeof v === 'string') {
obj = {};
obj[v] = stylus.url();
Object.assign(defines, obj);
} else {
obj = {};
obj[v.name] = stylus.url({
limit: v.limit != null ? v.limit : 30000,
paths: v.paths || []
});
Object.assign(defines, obj);
}
break;
case 'includeCSS':
k = 'include css';
default:
sets[k] = v;
}
});
opts.urlFn.forEach(function (el) {
s.define(el, stylus.url());
});
}
options.urlFunc.forEach(function(args){
s.define(args, stylus.url());
});
}
return function(style) {
style.define('url', stylus.url({res: 2}));
};
};