Added a auto generated comment to the generated files
parent
e3f4d67a0f
commit
c3b1a70f56
|
@ -1,3 +1,10 @@
|
|||
/*
|
||||
* DO NOT MODIFY THIS FILE!
|
||||
*
|
||||
* This file has been auto generated by the svg-sprite generator.
|
||||
* Sprite source directory: D:\git\web\webpack-svg-sprite\demo\sprites
|
||||
* Sprite count: 20
|
||||
*/
|
||||
declare module "svg-sprites/test" {
|
||||
export type TestIconClasses = "client-about" | "client-activate_microphone" | "client-add" | "client-add_foe" | "client-add_folder" | "client-add_friend" | "client-addon-collection" | "client-addon" | "client-apply" | "client-arrow_down" | "client-arrow_left" | "client-arrow_right" | "client-arrow_up" | "client-away" | "client-ban_client" | "client-ban_list" | "client-bookmark_add" | "client-bookmark_add_folder" | "client-bookmark_duplicate" | "client-w2g";
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ export = {
|
|||
module: true,
|
||||
enumName: "TestIcons",
|
||||
classUnionName: "TestIconClasses",
|
||||
cssClassPrefix: "client-",
|
||||
},
|
||||
cssOptions: [
|
||||
{
|
||||
|
|
|
@ -150,9 +150,19 @@ function generateEnumMembers(options: SpriteDtsOptions, sprite: GeneratedSprite,
|
|||
|
||||
return result;
|
||||
}
|
||||
export async function generateSpriteDts(options: SpriteDtsOptions, moduleName: string, sprite: GeneratedSprite, cssClassPrefix: string, modulePrefix: string) {
|
||||
export async function generateSpriteDts(options: SpriteDtsOptions, moduleName: string, sprite: GeneratedSprite, cssClassPrefix: string, modulePrefix: string, sourceDirectory: string) {
|
||||
const headerLines = [];
|
||||
const lines = [];
|
||||
|
||||
headerLines.push(`/*`);
|
||||
headerLines.push(` * DO NOT MODIFY THIS FILE!`);
|
||||
headerLines.push(` *`);
|
||||
headerLines.push(` * This file has been auto generated by the svg-sprite generator.`);
|
||||
headerLines.push(` * Sprite source directory: ${sourceDirectory}`);
|
||||
headerLines.push(` * Sprite count: ${sprite.entries.length}`);
|
||||
headerLines.push(` */`);
|
||||
headerLines.push(``);
|
||||
|
||||
{
|
||||
let union = "";
|
||||
for(const file of sprite.entries)
|
||||
|
@ -194,12 +204,13 @@ export async function generateSpriteDts(options: SpriteDtsOptions, moduleName: s
|
|||
|
||||
if(options.module) {
|
||||
let result = "";
|
||||
result += headerLines.join("\n");
|
||||
result += `declare module "${modulePrefix}${moduleName}" {\n`;
|
||||
result += lines.map(e => " " + e).join("\n");
|
||||
result += `\n}`;
|
||||
return result;
|
||||
} else {
|
||||
return lines.join("\n");
|
||||
return headerLines.join("\n") + lines.join("\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ class SvgSpriteModule extends Module {
|
|||
|
||||
this.spriteJs = await generateSpriteJs(this.config.dtsOptions, this.sprite, this.spriteAssetUrl, this.config.cssClassPrefix);
|
||||
|
||||
const dtsContent = await generateSpriteDts(this.config.dtsOptions, this.configName, this.sprite, this.config.cssClassPrefix, this.pluginConfig.modulePrefix);
|
||||
const dtsContent = await generateSpriteDts(this.config.dtsOptions, this.configName, this.sprite, this.config.cssClassPrefix, this.pluginConfig.modulePrefix, this.config.folder);
|
||||
await fs.writeFile(path.join(this.pluginConfig.dtsOutputFolder, this.configName + ".d.ts"), dtsContent);
|
||||
})().then(() => {
|
||||
callback();
|
||||
|
|
Loading…
Reference in New Issue