Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var content = [
'ie = ' + ie.toString(),
'@import "node_modules/stylobate";',
'rem = rem_px',
'@import "node_modules/stylobate-islands";',
'set-skin-namespace("islands");',
'@import "nanoislands.styl";'
].join('\n');
var stylus = require('stylus');
var autoprefixer = require('autoprefixer');
var style = stylus(content)
.set('filename', ie ? 'nanoislands.ie.css' : 'nanoislands.css')
.set('resolve url', true)
.define('url', stylus.resolver());
style.render(function(err, css) {
var browsers = [
// эти браузеры прибиты по версиям
'Opera 12',
'Safari >= 6',
'Explorer >= 9',
// эти браузеры обновляются автоматически
'last 5 Chrome versions',
'last 5 Firefox versions',
'last 5 Opera versions'
]
if (err) {
console.error(err);
process.exit(1);
if (_.isFunction(func)) {
s.use(func());
}
});
} else if (key === 'define') {
for (var defineName in value) {
s.define(defineName, value[defineName], shouldUseRawDefine(defineName));
}
} else if (key === 'rawDefine') {
// do nothing.
} else if (key === 'import') {
value.forEach(function(stylusModule) {
s.import(stylusModule);
});
} else if (key === 'resolve url') {
s.define('url', stylus.resolver());
} else if (key === 'resolve url nocheck') {
s.define('url', stylus.resolver({nocheck: true}));
} else {
s.set(key, value);
}
});
cmd += ` --include-path="${this.styleIncludePaths.join(':')}"`;
}
return execSync(cmd).toString();
case '.styl':
case '.stylus':
return (
stylus(content)
// add paths for resolve
.set('paths', [this.basePath, '.', ...this.styleIncludePaths, 'node_modules'])
// add support for resolving plugins from node_modules
.set('filename', filePath)
// turn on url resolver in stylus, same as flag --resolve-url
.set('resolve url', true)
.define('url', stylus.resolver(undefined))
.render()
);
case '.css':
default:
return content;
}
}
module.exports = ({ config, mode }) => {
config.module.rules.push({ // add stylus loader for component
exclude: /\/node_modules\//,
test: /\.styl$/,
use: [
'style-loader',
'css-loader',
{ loader: 'stylus-loader', options: { define: { url: stylus.resolver() } } },
],
})
return config
}
}, config);
// init the paths to search
let confPaths = config.paths || [];
[file.dirname].forEach(item => {
if (!confPaths.includes(item)) {
confPaths.push(item);
}
});
config.paths = confPaths;
let stylusUse = config.use;
delete config.use;
// http://stylus-lang.com/docs/js.html#stylusresolveroptions
let defineOpt = config.define || {url: stylus.resolver()};
delete config.define;
let compiler = stylus(file.content.toString());
Object.keys(config).forEach(key => {
compiler.set(key, config[key]);
});
compiler.use(function (style) {
if (typeof stylusUse === 'function') {
stylusUse(style);
}
defineOpt && Object.keys(defineOpt).forEach(name => {
style.define(name, defineOpt[name]);
});
});
var content = [
'ie = false;',
'@import "' + CURDIR + '/node_modules/stylobate";',
'rem = rem_px;',
'@import "' + CURDIR + '/node_modules/stylobate-islands";',
'set-skin-namespace(\'islands\');',
'@import "' + CURDIR + '/src/lib/styl/_colors.styl";',
'@import "' + CURDIR + '/src/lib/styl/_layout.styl";',
'@import "' + args.input + '";'
].join('\n');
var style = stylus(content)
.set('filename', filename)
.set('resolve url', true)
.define('url', stylus.resolver());
style.render(function(err, css) {
if (err) {
throw err;
}
if (!args.ie) {
css = autoprefixer.compile(css);
}
fs_.writeFileSync(args.output, css);
console.log('WRITE FILE: ', args.output);
});
async process({ code }) {
const stylus = require('stylus')
const style = stylus(code, { Evaluator: EnhancedEvaluator })
.set('filename', this.id)
.define('url', stylus.resolver())
const css = await pify(style.render.bind(style))()
return {
code: css,
map: style.sourcemap,
}
},
}
__DEBUG__: JSON.stringify(JSON.parse(!isBuild))
}),
copyWebpackPlugin([
{ from: './src/assets/soundfonts', to: './assets/soundfonts' },
]),
new webpack.optimize.CommonsChunkPlugin({
names: ['lib'],
chunks: ['lib', 'main'],
filename: scriptName,
minChunks: Infinity
})
]
exports.stylusConfig = {
define: {
url: stylus.resolver()
}
}
exports.htmlOptions = {
filename: './index.html',
template: './src/index.html',
inject: true
}
styl () {
return require( 'gulp-stylus' )({
'include css': true,
define: {
url: require( 'stylus' ).resolver()
},
})
},
})
.then(result => {
const file = result.css.toString();
return {
file,
getFileWithSourcemapUrl: _.partial(appendSourcemapUrl, file, destType, destDirname, destBasename),
sourcemap: sourcemap(src, srcDirname, srcBasename, destBasename, result.map, result.imports),
};
});
}
if (srcType === 'styl') {
let result;
const style = stylus(src)
.set('filename', srcPath)
.set('sourcemap', {comment: false})
.define('url', stylus.resolver());
style.render((err, css) => {
const file = css;
result = {
file,
getFileWithSourcemapUrl: _.partial(appendSourcemapUrl, file, destType, destDirname, destBasename),
sourcemap: sourcemap(src, srcDirname, srcBasename, destBasename, style.sourcemap, style.deps()),
};
});
return result;
}
if (srcType === 'coffee') {
const result = coffee.compile(src, {sourceMap: true, filename: srcPath, sourceFiles: [srcPath]});
const file = result.js;
return {