1
0
Fork 0

construction: Wow Rollup, you are sure giving me grief

This commit is contained in:
joostdecock 2018-07-26 10:03:19 +00:00 committed by Joost De Cock
parent 587f0e1ef9
commit ba2729811d
11 changed files with 1073 additions and 1021 deletions

3
packages/brian/.babelrc Normal file
View file

@ -0,0 +1,3 @@
{
"plugins": ["transform-object-rest-spread"]
}

View file

@ -1,10 +1,7 @@
/** Pattern parts */ /** Pattern parts */
export var config = { export default {
parts: [ name: "brian",
"back", parts: ["back", "front", "_sleeve"],
"front",
"_sleeve"
],
measurements: [ measurements: [
"bicepsCircumference", "bicepsCircumference",
"centerBackNeckToWaist", "centerBackNeckToWaist",
@ -19,26 +16,31 @@ export var config = {
], ],
options: [ options: [
// Constants // Constants
{ "id": "backNeckCutout", "val": 20, "type": "constant"}, { id: "backNeckCutout", val: 20, type: "constant" },
{ "id": "bicepsEase", "val": 50, "type": "constant"}, { id: "bicepsEase", val: 50, type: "constant" },
{ "id": "collarEase", "val": 15, "type": "constant"}, { id: "collarEase", val: 15, type: "constant" },
{ "id": "frontArmholeExtra", "val": 5, "type": "constant"}, { id: "frontArmholeExtra", val: 5, type: "constant" },
{ "id": "shoulderSlopeReduction", "val": 0, "type": "constant"}, { id: "shoulderSlopeReduction", val: 0, type: "constant" },
{ "id": "sleevecapEase", "val": 5, "type": "constant"}, { id: "sleevecapEase", val: 5, type: "constant" },
{ "id": "collarFactor", "val":4.8, "type": "constant"}, { id: "collarFactor", val: 4.8, type: "constant" },
// Measures // Measures
{ "id": "bicepsEase", "val": 50, "min": 30, "max": 80 }, { id: "bicepsEase", val: 50, min: 30, max: 80 },
{ "id": "chestEase", "val": 30, "min": -40, "max": 160 }, { id: "chestEase", val: 30, min: -40, max: 160 },
{ "id": "shoulderEase", "val": 0, "min": -20, "max": 60 }, { id: "shoulderEase", val: 0, min: -20, max: 60 },
{ "id": "cuffEase", "val": 45, "min": 0, "max": 100 }, { id: "cuffEase", val: 45, min: 0, max: 100 },
{ "id": "lengthBonus", "val": 0, "min": -40, "max": 120 }, { id: "lengthBonus", val: 0, min: -40, max: 120 },
{ "id": "sleeveLengthBonus", "val": 0, "min": -40, "max": 80 }, { id: "sleeveLengthBonus", val: 0, min: -40, max: 80 },
// Percentages // Percentages
{ "id": "acrossBackFactor", "val": 96, "type": "percentage", "min": 93, "max": 99 }, { id: "acrossBackFactor", val: 96, type: "percentage", min: 93, max: 99 },
{ "id": "armholeDepthFactor", "val": 50, "type": "percentage", "min": 35, "max": 65 }, { id: "armholeDepthFactor", val: 50, type: "percentage", min: 35, max: 65 },
{ "id": "sleevecapHeightFactor", "val": 55, "type": "percentage", "min": 35, "max": 75 } {
id: "sleevecapHeightFactor",
val: 55,
type: "percentage",
min: 35,
max: 75
}
] ]
}; };

View file

@ -1 +1 @@
../freesewing/dist/freesewing.min.js ../freesewing/dist/browser.js

View file

@ -7,15 +7,13 @@
<body> <body>
<div id="svg"></div> <div id="svg"></div>
<script type="text/javascript" src="freesewing.js"></script> <script type="text/javascript" src="freesewing.js"></script>
<script type="text/javascript" src="dist/brian.min.js"></script> <script type="text/javascript" src="dist/browser.js"></script>
<script type="text/javascript" src="theme.js"></script> <script type="text/javascript" src="https://unpkg.com/@freesewing/plugin-theme"></script>
<script type="text/javascript" src="designer.js"></script> <script type="text/javascript" src="https://unpkg.com/@freesewing/plugin-designer"></script>
<script type="text/javascript" src="cutonfold.min.js"></script>
<script> <script>
var pattern = freesewing.patterns.brian var pattern = freesewing.patterns.brian
.with(freesewing.plugins.theme) .with(freesewing.plugins.theme)
.with(freesewing.plugins.designer) .with(freesewing.plugins.designer);
.with(freesewing.plugins.cutonfold);
pattern.settings.measurements = { pattern.settings.measurements = {
bicepsCircumference: 335, bicepsCircumference: 335,

File diff suppressed because it is too large Load diff

View file

@ -24,6 +24,7 @@
"clean": "rimraf dist", "clean": "rimraf dist",
"pretty": "npx prettier --write \"src/*.js\"", "pretty": "npx prettier --write \"src/*.js\"",
"lint": "eslint --fix \"src/*.js\"", "lint": "eslint --fix \"src/*.js\"",
"watch": "rollup -w -c rollup.browser.js",
"browserbuild": "rollup -c rollup.browser.js", "browserbuild": "rollup -c rollup.browser.js",
"nodebuild": "rollup -c rollup.node.js", "nodebuild": "rollup -c rollup.node.js",
"build": "npm run clean && npm run browserbuild && npm run nodebuild" "build": "npm run clean && npm run browserbuild && npm run nodebuild"
@ -40,12 +41,15 @@
] ]
}, },
"dependencies": { "dependencies": {
"@freesewing-plugins/macro-cutonfold": "0.3.2", "@freesewing/plugin-cutonfold": "^0.5.0",
"@freesewing/plugin-logo": "^0.1.2",
"@freesewing/plugin-title": "^0.3.2",
"freesewing": "^0.3.3" "freesewing": "^0.3.3"
}, },
"devDependencies": { "devDependencies": {
"babel-core": "^6.26.3", "babel-core": "^6.26.3",
"babel-eslint": "^8.2.6", "babel-eslint": "^8.2.6",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"eslint": "^5.2.0", "eslint": "^5.2.0",
"eslint-config-prettier": "^2.9.0", "eslint-config-prettier": "^2.9.0",
"eslint-plugin-prettier": "^2.6.2", "eslint-plugin-prettier": "^2.6.2",

View file

@ -9,7 +9,7 @@ import meta from "./package.json";
export default { export default {
input: "src/index.js", input: "src/index.js",
output: { output: {
file: "dist/brian.min.js", file: "dist/browser.js",
format: "iife", format: "iife",
name: "freesewing.patterns.brian", name: "freesewing.patterns.brian",
globals: { globals: {

View file

@ -1,20 +1,17 @@
import { terser } from "rollup-plugin-terser";
import filesize from "rollup-plugin-filesize"; import filesize from "rollup-plugin-filesize";
import babel from "rollup-plugin-babel"; import babel from "rollup-plugin-babel";
import resolve from "rollup-plugin-node-resolve";
import json from "rollup-plugin-json"; import json from "rollup-plugin-json";
import resolve from "rollup-plugin-node-resolve";
import meta from "./package.json"; import meta from "./package.json";
export default { export default {
input: "src/index.js", input: "src/index.js",
output: { output: {
file: "dist/module.js", file: "dist/node.js",
format: "cjs", format: "cjs"
banner: `/**\n * ${meta.name} | v${meta.version}\n * ${
meta.description
}\n * (c) ${new Date().getFullYear()} ${meta.author}\n * @license ${
meta.license
}\n */`
}, },
external: ["freesewing"],
plugins: [ plugins: [
resolve({ resolve({
browser: false browser: false
@ -24,5 +21,14 @@ export default {
exclude: "node_modules/**" exclude: "node_modules/**"
}), }),
filesize() filesize()
//terser({
// output: {
// preamble: `/**\n * ${meta.name} | v${meta.version}\n * ${
// meta.description
// }\n * (c) ${new Date().getFullYear()} ${meta.author}\n * @license ${
// meta.license
// }\n */`
// }
//})
] ]
}; };

View file

@ -2,7 +2,7 @@ import * as F from "freesewing";
import base from "./base"; import base from "./base";
var back = { var back = {
draft: function(part, context) { draft: function(part) {
let { let {
measurements, measurements,
options, options,
@ -12,8 +12,8 @@ var back = {
macro, macro,
final, final,
paperless paperless
} = F.utils.shorthand(part, context); } = F.utils.shorthand(part);
base.draft(part, context); base.draft(part);
paths.seam = new F.path() paths.seam = new F.path()
.move(points.cbNeck) .move(points.cbNeck)
@ -33,24 +33,33 @@ var back = {
// Final? // Final?
var decorate = function(part, context) { var decorate = function(part) {
macro("cutonfold", { macro("cutonfold", {
from: points.cbNeck, from: points.cbNeck,
to: points.cbHips, to: points.cbHips,
grainline: true grainline: true
}); });
points.title = new F.point(
points.armholePitch.x / 2,
points.armholePitch.y
);
macro("title", {
at: points.title,
nr: 2
});
}; };
if (final) { if (final) {
decorate(part, context); decorate(part);
} }
// Paperless? // Paperless?
var gauge = function(part, context) {}; var gauge = function(part) {};
if (paperless) { if (paperless) {
gauge(part, context); gauge(part);
} }
} }
}; };

View file

@ -1,10 +1,9 @@
import * as F from "freesewing"; import * as F from "freesewing";
var base = { var base = {
draft: function(part, context) { draft: function(part) {
let { measurements, options, points, paths, snippets } = F.utils.shorthand( let { measurements, options, points, paths, snippets } = F.utils.shorthand(
part, part
context
); );
// Center back (cb) vertical axis // Center back (cb) vertical axis

View file

@ -1,19 +1,24 @@
import * as freesewing from "freesewing"; import freesewing from "freesewing";
import * as cutonfold from "@freesewing-plugins/macro-cutonfold"; import cutonfold from "@freesewing/plugin-cutonfold";
import { config } from "../config/config"; import * as plugintitle from "@freesewing/plugin-title";
//import logo from "@freesewing/plugin-logo";
import config from "../config/config";
import back from "./back"; import back from "./back";
import { version } from "../package.json"; import { version } from "../package.json";
console.log("title is ", plugintitle);
var pattern = new freesewing.pattern({ version: version, ...config })
.with(cutonfold)
.with(plugintitle);
// .with(logo)
//pattern.on("preRenderSvg", function(next) {
// this.attributes.add(`freesewing:${name}`, version);
// next();
//});
var brian = new freesewing.pattern(config).with(cutonfold); pattern.draft = function() {
brian.on("preRenderSvg", function(next) { back.draft(pattern.parts.back);
this.attributes.add("freesewing:brian", version);
next();
});
brian.draft = function() { return pattern;
back.draft(brian.parts.back, brian.context);
return brian;
}; };
export default brian; export default pattern;