当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript node-sass.render函数代码示例

本文整理汇总了TypeScript中node-sass.render函数的典型用法代码示例。如果您正苦于以下问题:TypeScript render函数的具体用法?TypeScript render怎么用?TypeScript render使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了render函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: Promise

  return new Promise((resolve, reject) => {

    sassConfig.omitSourceMapUrl = true;

    if (sassConfig.sourceMap) {
      sassConfig.sourceMap = basename(sassConfig.outFile);
      sassConfig.sourceMapContents = true;
    }

    nodeSassRender(sassConfig, (sassError: SassError, sassResult: Result) => {
      const diagnostics = runSassDiagnostics(context, sassError);

      if (diagnostics.length) {
        printDiagnostics(context, DiagnosticsType.Sass, diagnostics, true, true);
        // sass render error :(
        reject(new BuildError());

      } else {
        // sass render success :)
        renderSassSuccess(context, sassResult, sassConfig).then(outFile => {
          resolve(outFile);

        }).catch(err => {
          reject(new BuildError(err));
        });
      }
    });
  });
开发者ID:Kode-Kitchen,项目名称:ionic-app-scripts,代码行数:28,代码来源:sass.ts

示例2: Promise

  return new Promise((resolve, reject) => {

    sass.render(sassOpts, (err, result) => {
      if (err) {
        reject(err);
      } else {
        resolve(result.css.toString());
      }
    });
  });
开发者ID:davidenke,项目名称:ng-packagr,代码行数:10,代码来源:assets.ts

示例3: Promise

    return new Promise((resolve, reject) => {
        render({
            file: inFile,
            outputStyle: 'nested',
            outFile: outFile,
            sourceMap: false,
        }, (err, result) => {
            if (err)
                reject(err);
            else
                resolve(result);
        });

    });
开发者ID:danelkhen,项目名称:desktopbrowser,代码行数:14,代码来源:sass.ts

示例4: Promise

  return new Promise((resolve, reject) => {
    sass.render({
      file,
      sourceMap: false
    }, (err, result) => {
      if (err) {
        return reject(`failed to compile ${file}: ${err}`);
      }

      const css = result.css.toString();

      postcss([autoprefixer({browsers: ['last 2 versions']}), cssnano])
        .process(css)
        .then(postResult => {
          postResult.warnings().forEach(warn => {
              console.warn(warn.toString());
          });

          // do not write to file if output is identical to previous version
          const productionCss = postResult.css.toString();
          if (resourceChecksum.update(checksums, path.basename(outputFile), productionCss)) {
            console.log(`[scss]:${file}`);

            fs.writeFile(outputFile, productionCss, werr => {
              if (werr) {
                return reject(`faile to write css file: ${outputFile}: ${werr}`);
              }

              resolve(`${file} compiled`);
            });
          } else {
            console.log(`[unchanged]:${file}`);
            resolve(`${file} unchanged`);
          }
        });
    });
  });
开发者ID:cpylua,项目名称:cheli.im,代码行数:37,代码来源:styles.ts

示例5: function

sass.render({
  file: '/path/to/myFile.scss',
  data: 'body{background:blue; a{color:black;}}',
  importer: function(url, prev, done) {
    // url is the path in import as is, which libsass encountered.
    // prev is the previously resolved path.
    // done is an optional callback, either consume it or return value synchronously.
    // this.options contains this options hash, this.callback contains the node-style callback
    someAsyncFunction(url, prev, function(result) {
      done({
        file: result.path, // only one of them is required, see section Sepcial Behaviours.
        contents: result.data
      });
    });
    // OR
    var result = someSyncFunction(url, prev);
    return { file: result.path, contents: result.data };
  },
  includePaths: ['lib/', 'mod/'],
  outputStyle: 'compressed'
}, function(error, result) { // node-style callback from v3.0.0 onwards
  if (error) {
    console.log(error.status); // used to be "code" in v2x and below
    console.log(error.column);
    console.log(error.message);
    console.log(error.line);
  }
  else {
    console.log(result.css.toString());

    console.log(result.stats);

    console.log(result.map.toString());
    // or better
    console.log(JSON.stringify(result.map)); // note, JSON.stringify accepts Buffer too
  }
});
开发者ID:CNManning,项目名称:DefinitelyTyped,代码行数:37,代码来源:node-sass-tests.ts

示例6: done

        return;
      }
      accum = accum + $n.getValue();
    }
    done(sass.types.Number(accum, unit));
  }
};

const asyncFunctions: Record<string, sass.AsyncSassFunction> = {...asyncFunction, ...asyncVarArg};

const functions: sass.FunctionDeclarations = {...syncFunctions, ...asyncFunctions};

sass.render({
  file: '/path/to/myFile.scss',
  data: 'body{background:blue; a{color:black;}}',
  functions,
  importer: [anotherAsyncImporter, asyncImporter, syncImporter],
  includePaths: ['lib/', 'mod/'],
  outputStyle: 'compressed'
}, handleAsyncResult);

// OR

sass.render({
  file: '/path/to/myFile.scss',
  data: 'body{background:blue; a{color:black;}}',
  importer: asyncImporter,
  includePaths: ['lib/', 'mod/'],
  outputStyle: 'compressed'
}, handleAsyncResult);

// OR
开发者ID:CNBoland,项目名称:DefinitelyTyped,代码行数:32,代码来源:node-sass-tests.ts

示例7: function

sass.render({
  file: '/path/to/myFile.scss',
  data: 'body{background:blue; a{color:black;}}',
  importer: function(url, prev, done) {
    someAsyncFunction(url, prev, function(result) {
      if (result == null) {
        // return null to opt out of handling this path
        // compiler will fall to next importer in array (or its own default)
        return null;
      }
      // only one of them is required, see section Sepcial Behaviours.
      done({ file: result.path });
      done({ contents: result.data });
    });
  },
  includePaths: ['lib/', 'mod/'],
  outputStyle: 'compressed'
}, function(error, result) { // node-style callback from v3.0.0 onwards
  if (error) {
    console.log(error.status, error.column, error.message, error.line);
  }
  else {
    console.log(result.stats);
    console.log(result.css.toString());
    console.log(result.map.toString());
    // or better
    console.log(JSON.stringify(result.map)); // note, JSON.stringify accepts Buffer too
  }
});
// OR
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:30,代码来源:node-sass-tests.ts

示例8: Promise

 return new Promise((resolve, reject) => {
   render(opts, (err, res) => {
     if (err) return reject(err);
     return resolve(res.css.toString("utf8"));
   });
 });
开发者ID:tbtimes,项目名称:lede,代码行数:6,代码来源:SassCompiler.ts

示例9: renderFullPage

            let html = renderFullPage(
                css,
                renderToStaticMarkup(result.root),
                JSON.stringify(state)
            );

            res.send(html);

        } else {
            next();
        }

    };
}

sass.render({
  file: "./site.scss"
}, (error, result) => {
    if (error !== undefined) {
        let handleRender = getHandleRender(result.css.toString("utf8"));
        let app = express();
        let port = 3000;
        app.use(handleRender);
        app.use("/dist", express.static("dist"));
        app.listen(port);
    }
});

console.log("Starting up http-server on: http:127.0.0.1:3000");
开发者ID:redux-bootstrap,项目名称:redux-bootstrap-example,代码行数:29,代码来源:server.ts


注:本文中的node-sass.render函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。