Merge pull request #1 from freesewing-patterns/js
🚧 Moved from webpack to rollup
This commit is contained in:
parent
7f1bca7ed5
commit
bb7d34cd70
13 changed files with 2999 additions and 4416 deletions
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"presets": ["env"]
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/** Pattern parts */
|
||||
module.exports = {
|
||||
export var config = {
|
||||
parts: [
|
||||
"back",
|
||||
"front",
|
||||
|
|
1
packages/brian/freesewing.js
Symbolic link
1
packages/brian/freesewing.js
Symbolic link
|
@ -0,0 +1 @@
|
|||
../freesewing/dist/freesewing.min.js
|
|
@ -6,11 +6,12 @@
|
|||
</head>
|
||||
<body>
|
||||
<div id="svg"></div>
|
||||
<script type="text/javascript" src="dist/browser/bundle.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="theme-default.js"></script>
|
||||
<script type="text/javascript" src="theme-designer.js"></script>
|
||||
<script>
|
||||
var pattern = freesewing_patterns_brian;
|
||||
var pattern = freesewing.patterns.brian;
|
||||
pattern.settings.measurements = {
|
||||
bicepsCircumference: 335,
|
||||
centerBackNeckToWaist: 480,
|
||||
|
@ -23,33 +24,34 @@
|
|||
shoulderToWrist: 700,
|
||||
wristCircumference: 190
|
||||
};
|
||||
pattern.withPlugin(freesewing_theme_designer);
|
||||
pattern.withPlugin(freesewing_theme_default);
|
||||
pattern.on('preRenderSvg', function(next) {
|
||||
this.attributes.add('viewBox', '-10 -10 400 600');
|
||||
next();
|
||||
});
|
||||
pattern.draft();
|
||||
document.getElementById("svg").innerHTML = pattern.render();
|
||||
function pointHover(evt) {
|
||||
var point = evt.target;
|
||||
var id = point.id;
|
||||
var cx = point.getAttribute('x');
|
||||
var cy = point.getAttribute('y');
|
||||
var name = point.getAttribute('data-point');
|
||||
var part = point.getAttribute('data-part');
|
||||
console.log(name+' ('+cx+', '+cy+') @ '+part);
|
||||
var scale = 2;
|
||||
cx = cx-scale*cx;
|
||||
cy = cy-scale*cy;
|
||||
point.setAttribute("transform", 'matrix('+scale+', 0, 0, '+scale+', '+cx+', '+cy+')');
|
||||
pointUnhover(id);
|
||||
}
|
||||
function pointUnhover(id) {
|
||||
setTimeout(function(){
|
||||
document.getElementById(id).removeAttribute("transform", '');
|
||||
}, 500);
|
||||
}
|
||||
console.log(freesewing);
|
||||
//pattern.withPlugin(freesewing_theme_designer);
|
||||
//pattern.withPlugin(freesewing_theme_default);
|
||||
//pattern.on('preRenderSvg', function(next) {
|
||||
// this.attributes.add('viewBox', '-10 -10 400 600');
|
||||
// next();
|
||||
//});
|
||||
// pattern.draft();
|
||||
// document.getElementById("svg").innerHTML = pattern.render();
|
||||
// function pointHover(evt) {
|
||||
// var point = evt.target;
|
||||
// var id = point.id;
|
||||
// var cx = point.getAttribute('x');
|
||||
// var cy = point.getAttribute('y');
|
||||
// var name = point.getAttribute('data-point');
|
||||
// var part = point.getAttribute('data-part');
|
||||
// console.log(name+' ('+cx+', '+cy+') @ '+part);
|
||||
// var scale = 2;
|
||||
// cx = cx-scale*cx;
|
||||
// cy = cy-scale*cy;
|
||||
// point.setAttribute("transform", 'matrix('+scale+', 0, 0, '+scale+', '+cx+', '+cy+')');
|
||||
// pointUnhover(id);
|
||||
// }
|
||||
// function pointUnhover(id) {
|
||||
// setTimeout(function(){
|
||||
// document.getElementById(id).removeAttribute("transform", '');
|
||||
// }, 500);
|
||||
// }
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
7174
packages/brian/package-lock.json
generated
7174
packages/brian/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -21,25 +21,30 @@
|
|||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"clean": "rimraf dist",
|
||||
"nodebuild": "babel src -d dist/node",
|
||||
"browserbuild": "npx webpack-cli --config webpack.config.js",
|
||||
"watch": "npx webpack-cli --config webpack.config.js --watch",
|
||||
"build": "npm run clean && npm run nodebuild && npm run browserbuild",
|
||||
"dev": "webpack-dev-server --open"
|
||||
"browserbuild": "rollup -c rollup.browser.js",
|
||||
"nodebuild": "rollup -c rollup.node.js",
|
||||
"build": "npm run clean && npm run browserbuild && npm run nodebuild"
|
||||
},
|
||||
"dependencies": {
|
||||
"@freesewing-plugins/macro-cutonfold": "0.2.1",
|
||||
"freesewing": "^0.3.1"
|
||||
"freesewing": "^0.3.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.0.0-beta.53",
|
||||
"@babel/preset-env": "7.0.0-beta.53",
|
||||
"babel-preset-env": "1.7.0",
|
||||
"babel-core": "^6.26.3",
|
||||
"babel-eslint": "^8.2.6",
|
||||
"eslint": "^5.2.0",
|
||||
"eslint-config-prettier": "^2.9.0",
|
||||
"eslint-plugin-prettier": "^2.6.2",
|
||||
"husky": "^0.14.3",
|
||||
"lint-staged": "^7.2.0",
|
||||
"prettier": "^1.13.7",
|
||||
"rimraf": "^2.6.2",
|
||||
"babel-cli": "6.26.0",
|
||||
"babel-loader": "8.0.0-beta.4",
|
||||
"webpack": "4.16.0",
|
||||
"webpack-cli": "3.0.8"
|
||||
"rollup-plugin-babel": "^3.0.7",
|
||||
"rollup-plugin-commonjs": "^9.1.3",
|
||||
"rollup-plugin-filesize": "^4.0.1",
|
||||
"rollup-plugin-json": "^3.0.0",
|
||||
"rollup-plugin-node-resolve": "^3.3.0",
|
||||
"rollup-plugin-terser": "^1.0.1"
|
||||
},
|
||||
"files": [
|
||||
"dist/*",
|
||||
|
|
31
packages/brian/rollup.browser.js
Normal file
31
packages/brian/rollup.browser.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
import { terser } from "rollup-plugin-terser";
|
||||
import babel from 'rollup-plugin-babel';
|
||||
import resolve from 'rollup-plugin-node-resolve';
|
||||
import commonjs from "rollup-plugin-commonjs";
|
||||
import json from "rollup-plugin-json";
|
||||
import path from 'path';
|
||||
|
||||
export default {
|
||||
input: 'src/index.js',
|
||||
output: {
|
||||
file: 'dist/brian.min.js',
|
||||
format: 'iife',
|
||||
name: 'freesewing.patterns.brian',
|
||||
banner: `/**\n * Freesewing\n * (c) ${new Date().getFullYear()} Joost De Cock\n * @license MIT\n */`,
|
||||
globals: {
|
||||
freesewing: 'freesewing'
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
resolve({
|
||||
browser: true
|
||||
}),
|
||||
json(),
|
||||
babel({
|
||||
exclude: 'node_modules/**'
|
||||
}),
|
||||
],
|
||||
external: [
|
||||
'freesewing', path.resolve('./node_modules/freesewing/dist/freesewing.min.js')
|
||||
]
|
||||
};
|
22
packages/brian/rollup.node.js
Normal file
22
packages/brian/rollup.node.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
import filesize from 'rollup-plugin-filesize'
|
||||
import { terser } from "rollup-plugin-terser";
|
||||
import babel from 'rollup-plugin-babel';
|
||||
import resolve from 'rollup-plugin-node-resolve';
|
||||
|
||||
export default {
|
||||
input: 'src/index.js'
|
||||
, output: {
|
||||
file: 'dist/bundle.js'
|
||||
, format: 'cjs'
|
||||
}
|
||||
, plugins: [
|
||||
resolve({
|
||||
browser: false
|
||||
})
|
||||
, babel({
|
||||
exclude: 'node_modules/**'
|
||||
})
|
||||
, terser()
|
||||
, filesize()
|
||||
]
|
||||
};
|
|
@ -1,4 +1,4 @@
|
|||
import F from 'freesewing'
|
||||
import * as F from 'freesewing'
|
||||
import base from './base';
|
||||
|
||||
var back =
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import F from 'freesewing'
|
||||
import * as F from 'freesewing'
|
||||
|
||||
var base =
|
||||
{
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import F from 'freesewing'
|
||||
import cutonfold from '@freesewing-plugins/macro-cutonfold'
|
||||
import * as patternConfig from '../config/config'
|
||||
import * as freesewing from 'freesewing'
|
||||
import * as cutonfold from '@freesewing-plugins/macro-cutonfold'
|
||||
import { config } from '../config/config'
|
||||
import back from './back'
|
||||
|
||||
var brian = new F.pattern(patternConfig)
|
||||
import { version } from "../package.json"
|
||||
console.log('config', config);
|
||||
var brian = new freesewing.pattern(config)
|
||||
.withPlugin(cutonfold);
|
||||
|
||||
brian.draft = function()
|
||||
|
@ -13,4 +15,6 @@ brian.draft = function()
|
|||
return brian;
|
||||
}
|
||||
|
||||
module.exports = brian;
|
||||
brian.version = version;
|
||||
|
||||
export default brian;
|
||||
|
|
14
packages/brian/test.html
Normal file
14
packages/brian/test.html
Normal file
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Brian</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="svg"></div>
|
||||
<script type="text/javascript" src="freesewing.js"></script>
|
||||
<script>
|
||||
console.log(freesewing);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,35 +0,0 @@
|
|||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
mode: 'development',
|
||||
target: 'web',
|
||||
entry: './src/index.js',
|
||||
output: {
|
||||
path: path.resolve(__dirname, 'dist/browser'),
|
||||
filename: 'bundle.js',
|
||||
libraryTarget: 'var',
|
||||
library: 'freesewing_patterns_brian'
|
||||
},
|
||||
module: {
|
||||
rules:[
|
||||
{
|
||||
test: /\.js$/,
|
||||
exclude: /node_modules/,
|
||||
use: {
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
presets: ['@babel/preset-env']
|
||||
}
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
externals: {
|
||||
// require('data') is external and available
|
||||
// on the global var data
|
||||
'data': 'data'
|
||||
},
|
||||
devServer: {
|
||||
contentBase: path.resolve(__dirname)
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue