Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function createEsm(css) {
const { splitStyles } = require('@microsoft/load-themed-styles');
// Create a source file.
const source = [
`/* tslint:disable */`,
`import { loadStyles } from \'@microsoft/load-themed-styles\';`,
`loadStyles(${JSON.stringify(splitStyles(css))});`
];
return source.join('\n');
}
function createTypeScriptModule(fileName, css) {
const { splitStyles } = require("@microsoft/load-themed-styles");
// Create a source file.
const source = [
`/* tslint:disable */`,
`import { loadStyles } from \'@microsoft/load-themed-styles\';`,
`loadStyles(${JSON.stringify(splitStyles(css))});`
];
const map = _fileNameToClassMap[fileName];
for (let prop in map) {
source.push(`export const ${prop} = "${map[prop]}";`);
}
return source.join('\n');
}
function createTypeScriptModule(fileName, css) {
const { splitStyles } = require('@microsoft/load-themed-styles');
// Create a source file.
const source = [
`/* tslint:disable */`,
`import { loadStyles } from \'@microsoft/load-themed-styles\';`,
`loadStyles(${JSON.stringify(splitStyles(css))});`
];
const map = _fileNameToClassMap[fileName];
for (let prop in map) {
source.push(`export const ${prop} = "${map[prop]}";`);
}
return source.join('\n');
}
function createTypeScriptModule(fileName, css) {
const { splitStyles } = require('@microsoft/load-themed-styles');
// Create a source file.
const source = [
`/* tslint:disable */`,
`import { loadStyles } from \'@microsoft/load-themed-styles\';`,
`loadStyles(${JSON.stringify(splitStyles(css))});`
];
const map = _fileNameToClassMap[fileName];
for (let prop in map) {
source.push(`export const ${prop} = "${map[prop]}";`);
}
return source.join('\n');
}
let lines: string[] = [];
lines.push(this.taskConfig.preamble || '');
if (cssOutputPathAbsolute) {
lines = lines.concat([
`require(${JSON.stringify(`./${path.basename(cssOutputPathAbsolute)}`)});`,
stylesExportString
]);
} else if (content) {
lines = lines.concat([
'import { loadStyles } from \'@microsoft/load-themed-styles\';',
'',
stylesExportString,
'',
`loadStyles(${JSON.stringify(splitStyles(content))});`
]);
}
lines.push(this.taskConfig.postamble || '');
const generatedTsFile: string = (
lines
.join(EOL)
.replace(new RegExp(`(${EOL}){3,}`, 'g'), `${EOL}${EOL}`)
.replace(new RegExp(`(${EOL})+$`, 'm'), EOL)
);
FileSystem.writeFile(scssTsOutputPath, generatedTsFile);
});
}
let lines: string[] = [];
lines.push(this.taskConfig.preamble || '');
if (this.taskConfig.dropCssFiles) {
lines = lines.concat([
`require('./${path.basename(file.path, scssTsExtName)}.css');`,
exportClassNames
]);
} else if (!!content) {
lines = lines.concat([
'import { loadStyles } from \'@microsoft/load-themed-styles\';',
'',
exportClassNames,
'',
`loadStyles(${JSON.stringify(splitStyles(content))});`
]);
}
lines.push(this.taskConfig.postamble || '');
return (
lines
.join(EOL)
.replace(new RegExp(`(${EOL}){3,}`, 'g'), `${EOL}${EOL}`)
.replace(new RegExp(`(${EOL})+$`, 'm'), EOL)
);
}
}))