fix build, cleanup #3
File diff suppressed because it is too large
Load Diff
14
package.json
14
package.json
|
@ -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",
|
||||
|
@ -41,4 +39,4 @@
|
|||
"path": "^0.12.7",
|
||||
"webpack": "^5.x"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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,24 +215,22 @@ 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) {
|
||||
lines.push(` Object.freeze({`);
|
||||
lines.push(` id: "${entry.name}",`);
|
||||
lines.push(` className: "${cssClassPrefix}${entry.name}",`);
|
||||
lines.push(``);
|
||||
lines.push(`let SpriteEntries = [`);
|
||||
for(const entry of sprite.entries) {
|
||||
lines.push(` Object.freeze({`);
|
||||
lines.push(` id: "${entry.name}",`);
|
||||
lines.push(` className: "${cssClassPrefix}${entry.name}",`);
|
||||
|
||||
lines.push(` width: ${entry.bounds.w},`);
|
||||
lines.push(` height: ${entry.bounds.h},`);
|
||||
lines.push(` width: ${entry.bounds.w},`);
|
||||
lines.push(` height: ${entry.bounds.h},`);
|
||||
|
||||
lines.push(` xOffset: ${entry.bounds.x},`);
|
||||
lines.push(` yOffset: ${entry.bounds.y},`);
|
||||
lines.push(` xOffset: ${entry.bounds.x},`);
|
||||
lines.push(` yOffset: ${entry.bounds.y},`);
|
||||
|
||||
lines.push(` }),`);
|
||||
}
|
||||
lines.push(`];`);
|
||||
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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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: [
|
||||
|
|
Loading…
Reference in New Issue