How to use the stylus.resolver function in stylus

To help you get started, we’ve selected a few stylus examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yandex-ui / nanoislands / build / build-styl.js View on Github external
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);
github gruntjs / grunt-contrib-stylus / tasks / stylus.js View on Github external
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);
      }
    });
github ng-packagr / ng-packagr / src / lib / ng-v5 / entry-point / resources / stylesheet-processor.ts View on Github external
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;
    }
  }
github mockingbot / ibot / .storybook / webpack.config.js View on Github external
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
}
github ecomfe / okam / packages / okam-build / lib / processor / css / stylus.js View on Github external
}, 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]);
        });
    });
github Katochimoto / xblocks / bin / styl.js View on Github external
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);
});
github mockingbot / ibot / scripts / stylus-loader.js View on Github external
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,
    }
  },
}
github SuneBear / Piano-Flow / tools / webpack.config.common.js View on Github external
__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
}
github werty1001 / bemgo / tasks / styles.js View on Github external
styl () {
		return require( 'gulp-stylus' )({
			'include css': true,
			define: {
				url: require( 'stylus' ).resolver()
			},
		})
	},
github millwrightjs / millwright / utils / template-deps.js View on Github external
})
      .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 {