diff --git a/package.json b/package.json index ef27c6f..efec211 100644 --- a/package.json +++ b/package.json @@ -2,10 +2,10 @@ "name": "skinview3d", "version": "1.0.2", "description": "Three.js powered Minecraft skin viewer", - "module": "build/skinview3d.babel.module.js", - "main": "build/skinview3d.babel.min.js", + "module": "build/skinview3d.module.js", + "main": "build/skinview3d.js", "scripts": { - "build": "rollup -c tools/rollup.default.js && rollup -c tools/rollup.min.js && rollup -c tools/rollup.babel.js && rollup -c tools/rollup.babel.min.js", + "build": "rollup -c tools/rollup.module.js && rollup -c tools/rollup.browser.js && rollup -c tools/rollup.browser.min.js", "prepare": "npm test && rm -rf build && npm run build", "test": "eslint src/** tools/**" }, diff --git a/src/orbit_controls.js b/src/orbit_controls.js index ea61ae9..ec082a6 100644 --- a/src/orbit_controls.js +++ b/src/orbit_controls.js @@ -1,34 +1,33 @@ -/** - * @license - * Copyright (C) 2010-2017 three.js authors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -/** - * @preserve - * The code was originally from https://github.com/mrdoob/three.js/blob/d45a042cf962e9b1aa9441810ba118647b48aacb/examples/js/controls/OrbitControls.js - */ import THREE from "three"; class OrbitControls extends THREE.EventDispatcher { /** * @preserve + * The code was originally from https://github.com/mrdoob/three.js/blob/d45a042cf962e9b1aa9441810ba118647b48aacb/examples/js/controls/OrbitControls.js + */ + /** + * @license + * Copyright (C) 2010-2017 three.js authors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * * @author qiao / https://github.com/qiao * @author mrdoob / http://mrdoob.com * @author alteredq / http://alteredqualia.com/ diff --git a/tools/rollup.common.js b/tools/rollup-util.js similarity index 63% rename from tools/rollup.common.js rename to tools/rollup-util.js index ffefadb..ec9782b 100644 --- a/tools/rollup.common.js +++ b/tools/rollup-util.js @@ -10,38 +10,43 @@ let buildType = config => { globals: { three: "THREE" }, - output: [ - { + output: [], + plugins: [] + }; + + switch (config.format) { + case "umd": + options.output.push({ format: "umd", name: "skinview3d", file: `build/skinview3d${config.postfix}.js` - }, - { + }); + break; + + case "es": + options.output.push({ format: "es", - file: `build/skinview3d${config.postfix}.module.js` - } - ], - plugins: [] - }; + file: `build/skinview3d${config.postfix}.js` + }); + break; + + default: + throw `Unknown format: ${config.format}`; + } + if (config.babel) { options.plugins.push( babel({ - exclude: "node_modules/**", + exclude: "node_modules/**" }) ); } + if (config.uglify) { options.plugins.push( uglify({ output: { - comments: (node, comment) => { - let text = comment.value; - let type = comment.type; - if (type == "comment2") { - // multiline comment - return /@preserve|@license|@cc_on/i.test(text); - } - } + comments: "some" } }, minify) ); diff --git a/tools/rollup.babel.js b/tools/rollup.babel.js deleted file mode 100644 index 67d8576..0000000 --- a/tools/rollup.babel.js +++ /dev/null @@ -1,2 +0,0 @@ -import { buildType } from "./rollup.common"; -export default buildType({ postfix: ".babel", babel: true, uglify: false }); diff --git a/tools/rollup.babel.min.js b/tools/rollup.babel.min.js deleted file mode 100644 index 8467b2e..0000000 --- a/tools/rollup.babel.min.js +++ /dev/null @@ -1,2 +0,0 @@ -import { buildType } from "./rollup.common"; -export default buildType({ postfix: ".babel.min", babel: true, uglify: true }); diff --git a/tools/rollup.browser.js b/tools/rollup.browser.js new file mode 100644 index 0000000..a05689c --- /dev/null +++ b/tools/rollup.browser.js @@ -0,0 +1,7 @@ +import { buildType } from "./rollup-util"; +export default buildType({ + postfix: "", + babel: true, + uglify: false, + format: "umd" +}); diff --git a/tools/rollup.browser.min.js b/tools/rollup.browser.min.js new file mode 100644 index 0000000..c31a19d --- /dev/null +++ b/tools/rollup.browser.min.js @@ -0,0 +1,7 @@ +import { buildType } from "./rollup-util"; +export default buildType({ + postfix: ".min", + babel: true, + uglify: true, + format: "umd" +}); diff --git a/tools/rollup.default.js b/tools/rollup.default.js deleted file mode 100644 index f0471ca..0000000 --- a/tools/rollup.default.js +++ /dev/null @@ -1,2 +0,0 @@ -import { buildType } from "./rollup.common"; -export default buildType({ postfix: "", babel: false, uglify: false }); diff --git a/tools/rollup.min.js b/tools/rollup.min.js deleted file mode 100644 index 54db5a3..0000000 --- a/tools/rollup.min.js +++ /dev/null @@ -1,2 +0,0 @@ -import { buildType } from "./rollup.common"; -export default buildType({ postfix: ".min", babel: false, uglify: true }); diff --git a/tools/rollup.module.js b/tools/rollup.module.js new file mode 100644 index 0000000..0b4f534 --- /dev/null +++ b/tools/rollup.module.js @@ -0,0 +1,7 @@ +import { buildType } from "./rollup-util"; +export default buildType({ + postfix: ".module", + babel: false, + uglify: false, + format: "es" +});