當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript node-sass.renderSync函數代碼示例

本文整理匯總了TypeScript中node-sass.renderSync函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript renderSync函數的具體用法?TypeScript renderSync怎麽用?TypeScript renderSync使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了renderSync函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: test

  test(`It should import only specific custom nodes.`, () => {
    const expectedResult = fs.readFileSync(`test/files/filter-import-custom.css`, {
      encoding: `utf8`,
    });
    const options = {
      customFilters: {
        customMediaWidth: [
          [
            { property: `type`, value: `atrule` },
            { property: `name`, value: `media` },
            { property: `params`, value: `(min-width: 42em)` },
          ],
        ],
        customMediaPrint: [
          [
            { property: `type`, value: `atrule` },
            { property: `name`, value: `media` },
            { property: `params`, value: `print` },
          ],
        ],
      },
    };

    const result = sass.renderSync({
      file: `test/files/filter-import-custom.scss`,
      importer: magicImporter(options) as any,
    }).css.toString();

    expect(result).toBe(expectedResult);
  });
開發者ID:maoberlehner,項目名稱:node-sass-magic-importer,代碼行數:30,代碼來源:magic-importer.test.ts

示例2: compile

	exports.compile = function compile(buffer, stream) {
		stream.write(sass.renderSync({
			data:		buffer,
			error:		function (e) {
				throw new Error(e);
			}
		}));
	};
開發者ID:jspdown,項目名稱:webkool,代碼行數:8,代碼來源:sass.ts

示例3: Buffer

 Config.transformStyle = (source: string, url: string, d: Decorator) => {
   const res = sass.renderSync({
     sourceMap: true, data: source, sourceMapEmbed: true
   });
   const code = res.css.toString();
   const base64Map = code.match(/\/\*(.*?)\*\//)[1].replace('# sourceMappingURL=data:application/json;base64,', '');
   const map = JSON.parse(new Buffer(base64Map, 'base64').toString('ascii'));
   return { code, source, map };
 };
開發者ID:SteveVanOpstal,項目名稱:codelyzer,代碼行數:9,代碼來源:noUnusedCssRule.spec.ts

示例4: test

  test(`Should not fail when dir is empty.`, () => {
    const expectedResult = ``;

    const result = sass.renderSync({
      file: `test/files/glob-import-empty-dir.scss`,
      importer: globImporter(),
    }).css.toString();

    expect(result).toBe(expectedResult);
  });
開發者ID:maoberlehner,項目名稱:node-sass-magic-importer,代碼行數:10,代碼來源:glob-importer.test.ts

示例5: test

  test(`It should import only specific nodes.`, () => {
    const expectedResult = fs.readFileSync(`test/files/filter-import.css`, {
      encoding: `utf8`,
    });

    const result = sass.renderSync({
      file: `test/files/filter-import.scss`,
      importer: filterImporter(),
    }).css.toString();

    expect(result).toBe(expectedResult);
  });
開發者ID:maoberlehner,項目名稱:node-sass-magic-importer,代碼行數:12,代碼來源:filter-importer.test.ts

示例6: _compileSCSS

  /**
   * Compiles SCSS to CSS and passes it through Autoprefixer.
   */
  static _compileSCSS(styles: string): string {
    let compiled = sass.renderSync({
      data: styles,
      outputStyle: 'compressed'
    }).css.toString();


    let prefixer = autoprefixer({
      browsers: ['last 2 versions', 'last 4 Android versions']
    });

    return postcss(prefixer).process(compiled).css;
  }
開發者ID:angular,項目名稱:material-tools,代碼行數:16,代碼來源:CSSBuilder.ts

示例7: test

  test(`It should import files from modules.`, () => {
    const expectedResult = fs.readFileSync(`test/files/package-import.css`, {
      encoding: `utf8`,
    });
    const result = sass.renderSync({
      file: `test/files/package-import.scss`,
      importer: packageImporter({
        cwd: `${__dirname}/files`,
      }),
    }).css.toString();

    expect(result).toBe(expectedResult);
  });
開發者ID:maoberlehner,項目名稱:node-sass-magic-importer,代碼行數:13,代碼來源:package-importer.test.ts


注:本文中的node-sass.renderSync函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。