本文整理汇总了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);
});
示例2: compile
exports.compile = function compile(buffer, stream) {
stream.write(sass.renderSync({
data: buffer,
error: function (e) {
throw new Error(e);
}
}));
};
示例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 };
};
示例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);
});
示例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);
});
示例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;
}
示例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);
});