How to use the less.render function in less

To help you get started, we’ve selected a few less 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 will123195 / bleh / lib / build / less.js View on Github external
function saveLess (file, done) {
    var lessCode = fs.readFileSync(file.filename, 'utf8')
    less.render(lessCode, {
      paths: [                // Specify search paths for @import directives
        root,
        path.join(opts.main, 'node_modules', 'bleh', 'shared')
      ],
      filename: file.name,    // Specify a filename, for better error messages
      compress: false         // Minify CSS output
    }, function (err, cssCode) {
      if (err) {
        return done(err)
      }
      var cachebust = MD5(cssCode.css).substring(0, 8)
      var name = file.filename.replace(root + path.sep, '')
      var view = getViewName({
        name: name.replace('.less', '')
      })
      var uri = assetsUri + view + '.css'
github amzn / style-dictionary / test / formats / lessVariables.js View on Github external
it('should have a valid less syntax', function(done) {
      less
        .render(formatter(dictionary))
        .then(function(output) {
          assert.isDefined(output);
          done();
        })
        .catch(function(err) {
          done(new Error(err));
        });
    });
  });
github ecomfe / est / compile.js View on Github external
(function (code) {
            less.render(code, {
                plugins: [new Est()],
                modifyVars: {
                    'support-ie-version': '7',
                    'use-autoprefixer': 'false'
                }
            }).then(function (output) {
                var compiled = output.css;
                try {
                    compiled = postcss([
                        perfectionist({
                            maxSelectorLength: 1
                        })
                    ]).process(compiled).css;
                } catch (e) {
                    console.log(e);
                    console.log(compiled);
github Tencent / omi / packages / mps / gulpfile.js View on Github external
function compileLess(file, watch) {
  var dir = path.dirname(file.path)
  var name = path.basename(file.path, '.less')
  console.log('[编译文件]'.green, file.path)

  less.render(file.contents, {
    paths: ['.', './common-less'],
  }, function (e, output) {
    console.log('[编译完成]'.green, file.path)

    fs.writeFileSync(dir + '/' + name + '.wxss', output.css)
    console.log('[写入文件]'.green, name + '.wxss')

    if (watch) {
      console.log('[编译完成]'.green, name + '.wxss')
      console.log('[监听更改]'.green, '...')
    }
  });

}
github sheinsight / shineout / scripts / build-css.js View on Github external
return new Promise((resolve, reject) => {
    less.render(data, setting, (err, d) => {
      if (err) {
        reject(err)
        return
      }
      resolve(d.css)
    })
  })
}
github jasonsanjose / brackets-sass / node / 2.0.1 / node_modules / node-sass / node_modules / mocha / node_modules / jade / jade.js View on Github external
less: function(str){
    var ret;
    str = str.replace(/\\n/g, '\n');
    require('less').render(str, function(err, css){
      if (err) throw err;
      ret = '<style type="text/css">' + css.replace(/\n/g, '\\n') + '</style>';  
    });
    return ret;
  },
github felixge / node-romulus / lib / renderLessFile.js View on Github external
fs.readFile(path, 'utf-8', function(err, lessSource) {
    if (err) return cb(err);

    var options = {filename: path};
    less.render(lessSource, options, function(err, css) {
      if (err) {
        cb(formatError(err));
        return;
      }

      cb(null, css);
    });
  });
};
github BinaryMuse / react-atomshell-spotify / src / client / main.js View on Github external
async function loadStyles() {
  const lessData = readFileSync(`${__dirname}/style/style.less`, 'utf8');
  const {css} = await less.render(lessData, {
    paths: [resolve(`${__dirname}/..`)],
    filename: 'style.less'
  });
  const node = document.createElement("style");
  node.innerHTML = css;
  document.head.appendChild(node);
}
github mrmckeb / typescript-plugin-css-modules / src / helpers / cssSnapshots.ts View on Github external
export const getClasses = (css: string, fileName: string) => {
  try {
    const fileType = getFileType(fileName);
    let transformedCss = '';

    if (fileType === FileTypes.less) {
      less.render(css, { asyncImport: true } as any, (err, output) => {
        transformedCss = output.css.toString();
      });
    } else if (fileType === FileTypes.scss) {
      const filePath = getFilePath(fileName);
      transformedCss = sass
        .renderSync({
          data: css,
          includePaths: [filePath],
        })
        .css.toString();
    } else {
      transformedCss = css;
    }

    const processedCss = processor.process(transformedCss);
github kristerkari / react-native-less-transformer / index.js View on Github external
var lessPromise = new Promise((resolve, reject) => {
    less
      .render(src, { paths: [path.dirname(filename), appRoot] })
      .then(result => {
        resolve(result.css);
      })
      .catch(reject);
  });
  return lessPromise;