Compare commits

...

2 Commits

Author SHA1 Message Date
gapodo 2b46534195 Merge pull request 'fix build, cleanup' (#3) from webpack-v5 into master
Reviewed-on: #3
2023-11-16 20:06:46 +00:00
gapodo a8e3311b9c fix build, cleanup 2023-11-16 21:06:12 +01:00
5 changed files with 683 additions and 560 deletions

1181
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,29 +1,27 @@
{
"name": "webpack-svg-sprite-generator",
"version": "5.0.6",
"version": "5.0.7",
"description": "",
"main": "plugin.js",
"types": "ts/index.d.ts",
"scripts": {
"build": "webpack",
"build-demo": "webpack --config demo/webpack.config.js",
"serve-demo": "webpack-dev-server --config demo/webpack.config.js"
"build": "webpack"
},
"keywords": [],
"author": "WolverinDEV",
"license": "GPL-3.0",
"bugs": {
"url": "https://github.com/WolverinDEV/webpack-svg-sprites/issues"
"url": "https://git.kle.li/TeaSpeak/webpack-svg-sprites/issues"
},
"repository": {
"url": "https://github.com/WolverinDEV/webpack-svg-sprites",
"url": "https://git.kle.li/TeaSpeak/webpack-svg-sprites.git",
"type": "git"
},
"devDependencies": {
"@types/fs-extra": "^11.0.4",
"@types/tapable": "^2.2.7",
"@types/webpack": "^5.28.5",
"change-case": "^5.1.2",
"change-case": "^4.1.2",
"clean-webpack-plugin": "^4.0.0",
"copy-webpack-plugin": "^11.0.0",
"html-webpack-plugin": "^5.5.3",

View File

@ -99,15 +99,6 @@ export async function generateSpriteCss(options: SpriteCssOptions, classPrefix:
result += `width:${defaultWidth * scaleX}${options.unit}`;
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) => {
let valStr = value.toString();
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)
union += ` | "${cssClassPrefix}${file.name}"`;
lines.push(`export type ${options.classUnionName} = ${union.substr(3)};`);
lines.push(`export type ${options.classUnionName} = ${union.substring(3)};`);
}
lines.push(``);
@ -224,7 +215,6 @@ export async function generateSpriteJs(options: SpriteDtsOptions, sprite: Genera
lines.push(`EnumClassList[EnumClassList["${key}"] = "${members[key]}"] = "${key}";`);
}
{
lines.push(``);
lines.push(`let SpriteEntries = [`);
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(`let SpriteUrl = decodeURIComponent("${encodeURIComponent(publicUrl)}");`);
@ -310,13 +299,8 @@ export async function generateSprite(files: string[]) : Promise<GeneratedSprite>
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));
//result.entries.forEach(e => { e.bounds.w -= svgSpaceWidth; e.bounds.h -= svgSpaceHeight });
result.width = spriteDim.w;
result.height = spriteDim.h;

View File

@ -205,7 +205,7 @@ export class SpriteGenerator {
return;
}
const configName = resolveData.request.substr(this.options.modulePrefix.length);
const configName = resolveData.request.substring(this.options.modulePrefix.length);
if(!this.options.configurations[configName]) {
return;
}

View File

@ -3,7 +3,7 @@ import {Configuration} from "webpack";
import {CleanWebpackPlugin} from "clean-webpack-plugin";
import CopyWebpackPlugin from "copy-webpack-plugin";
export = {
export default {
entry: "./plugin/index.ts",
module: {
rules: [