commit
2b46534195
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
|
@ -1,29 +1,27 @@
|
||||||
{
|
{
|
||||||
"name": "webpack-svg-sprite-generator",
|
"name": "webpack-svg-sprite-generator",
|
||||||
"version": "5.0.6",
|
"version": "5.0.7",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "plugin.js",
|
"main": "plugin.js",
|
||||||
"types": "ts/index.d.ts",
|
"types": "ts/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "webpack",
|
"build": "webpack"
|
||||||
"build-demo": "webpack --config demo/webpack.config.js",
|
|
||||||
"serve-demo": "webpack-dev-server --config demo/webpack.config.js"
|
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "WolverinDEV",
|
"author": "WolverinDEV",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/WolverinDEV/webpack-svg-sprites/issues"
|
"url": "https://git.kle.li/TeaSpeak/webpack-svg-sprites/issues"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"url": "https://github.com/WolverinDEV/webpack-svg-sprites",
|
"url": "https://git.kle.li/TeaSpeak/webpack-svg-sprites.git",
|
||||||
"type": "git"
|
"type": "git"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/fs-extra": "^11.0.4",
|
"@types/fs-extra": "^11.0.4",
|
||||||
"@types/tapable": "^2.2.7",
|
"@types/tapable": "^2.2.7",
|
||||||
"@types/webpack": "^5.28.5",
|
"@types/webpack": "^5.28.5",
|
||||||
"change-case": "^5.1.2",
|
"change-case": "^4.1.2",
|
||||||
"clean-webpack-plugin": "^4.0.0",
|
"clean-webpack-plugin": "^4.0.0",
|
||||||
"copy-webpack-plugin": "^11.0.0",
|
"copy-webpack-plugin": "^11.0.0",
|
||||||
"html-webpack-plugin": "^5.5.3",
|
"html-webpack-plugin": "^5.5.3",
|
||||||
|
|
|
@ -99,15 +99,6 @@ export async function generateSpriteCss(options: SpriteCssOptions, classPrefix:
|
||||||
result += `width:${defaultWidth * scaleX}${options.unit}`;
|
result += `width:${defaultWidth * scaleX}${options.unit}`;
|
||||||
result += `}`;
|
result += `}`;
|
||||||
|
|
||||||
/*
|
|
||||||
const unit = (value: number) => {
|
|
||||||
let valStr = value.toString();
|
|
||||||
if(valStr.length < 5)
|
|
||||||
valStr = " ".substr(valStr.length - 5) + valStr;
|
|
||||||
|
|
||||||
return value === 0 ? `${valStr} ` : `${valStr}${options.unit}`;
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
const unit = (value: number) => {
|
const unit = (value: number) => {
|
||||||
let valStr = value.toString();
|
let valStr = value.toString();
|
||||||
return value === 0 ? `${valStr}` : `${valStr}${options.unit}`;
|
return value === 0 ? `${valStr}` : `${valStr}${options.unit}`;
|
||||||
|
@ -168,7 +159,7 @@ export async function generateSpriteDts(options: SpriteDtsOptions, moduleName: s
|
||||||
for(const file of sprite.entries)
|
for(const file of sprite.entries)
|
||||||
union += ` | "${cssClassPrefix}${file.name}"`;
|
union += ` | "${cssClassPrefix}${file.name}"`;
|
||||||
|
|
||||||
lines.push(`export type ${options.classUnionName} = ${union.substr(3)};`);
|
lines.push(`export type ${options.classUnionName} = ${union.substring(3)};`);
|
||||||
}
|
}
|
||||||
|
|
||||||
lines.push(``);
|
lines.push(``);
|
||||||
|
@ -224,7 +215,6 @@ export async function generateSpriteJs(options: SpriteDtsOptions, sprite: Genera
|
||||||
lines.push(`EnumClassList[EnumClassList["${key}"] = "${members[key]}"] = "${key}";`);
|
lines.push(`EnumClassList[EnumClassList["${key}"] = "${members[key]}"] = "${key}";`);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
lines.push(``);
|
lines.push(``);
|
||||||
lines.push(`let SpriteEntries = [`);
|
lines.push(`let SpriteEntries = [`);
|
||||||
for(const entry of sprite.entries) {
|
for(const entry of sprite.entries) {
|
||||||
|
@ -241,7 +231,6 @@ export async function generateSpriteJs(options: SpriteDtsOptions, sprite: Genera
|
||||||
lines.push(` }),`);
|
lines.push(` }),`);
|
||||||
}
|
}
|
||||||
lines.push(`];`);
|
lines.push(`];`);
|
||||||
}
|
|
||||||
|
|
||||||
lines.push(``);
|
lines.push(``);
|
||||||
lines.push(`let SpriteUrl = decodeURIComponent("${encodeURIComponent(publicUrl)}");`);
|
lines.push(`let SpriteUrl = decodeURIComponent("${encodeURIComponent(publicUrl)}");`);
|
||||||
|
@ -310,13 +299,8 @@ export async function generateSprite(files: string[]) : Promise<GeneratedSprite>
|
||||||
result.entries.push(svg);
|
result.entries.push(svg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* take the element height/with divided by two since that's a good number to work with */
|
|
||||||
//const svgSpaceWidth = result.elementWidth / 2;
|
|
||||||
//const svgSpaceHeight = result.elementHeight / 2;
|
|
||||||
|
|
||||||
//result.entries.forEach(e => { e.bounds.w += svgSpaceWidth; e.bounds.h += svgSpaceHeight });
|
|
||||||
const spriteDim = potpack(result.entries.map(e => e.bounds));
|
const spriteDim = potpack(result.entries.map(e => e.bounds));
|
||||||
//result.entries.forEach(e => { e.bounds.w -= svgSpaceWidth; e.bounds.h -= svgSpaceHeight });
|
|
||||||
|
|
||||||
result.width = spriteDim.w;
|
result.width = spriteDim.w;
|
||||||
result.height = spriteDim.h;
|
result.height = spriteDim.h;
|
||||||
|
|
|
@ -205,7 +205,7 @@ export class SpriteGenerator {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const configName = resolveData.request.substr(this.options.modulePrefix.length);
|
const configName = resolveData.request.substring(this.options.modulePrefix.length);
|
||||||
if(!this.options.configurations[configName]) {
|
if(!this.options.configurations[configName]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {Configuration} from "webpack";
|
||||||
import {CleanWebpackPlugin} from "clean-webpack-plugin";
|
import {CleanWebpackPlugin} from "clean-webpack-plugin";
|
||||||
import CopyWebpackPlugin from "copy-webpack-plugin";
|
import CopyWebpackPlugin from "copy-webpack-plugin";
|
||||||
|
|
||||||
export = {
|
export default {
|
||||||
entry: "./plugin/index.ts",
|
entry: "./plugin/index.ts",
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
|
|
Loading…
Reference in New Issue