refactor build
This commit is contained in:
parent
9f30b25d3e
commit
c3c5863263
|
|
@ -2,10 +2,10 @@
|
||||||
"name": "skinview3d",
|
"name": "skinview3d",
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"description": "Three.js powered Minecraft skin viewer",
|
"description": "Three.js powered Minecraft skin viewer",
|
||||||
"module": "build/skinview3d.babel.module.js",
|
"module": "build/skinview3d.module.js",
|
||||||
"main": "build/skinview3d.babel.min.js",
|
"main": "build/skinview3d.js",
|
||||||
"scripts": {
|
"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",
|
"prepare": "npm test && rm -rf build && npm run build",
|
||||||
"test": "eslint src/** tools/**"
|
"test": "eslint src/** tools/**"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,10 @@
|
||||||
|
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
|
* @license
|
||||||
* Copyright (C) 2010-2017 three.js authors
|
* Copyright (C) 2010-2017 three.js authors
|
||||||
|
|
@ -19,16 +26,8 @@
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
* 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
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* THE SOFTWARE.
|
* 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
|
|
||||||
* @author qiao / https://github.com/qiao
|
* @author qiao / https://github.com/qiao
|
||||||
* @author mrdoob / http://mrdoob.com
|
* @author mrdoob / http://mrdoob.com
|
||||||
* @author alteredq / http://alteredqualia.com/
|
* @author alteredq / http://alteredqualia.com/
|
||||||
|
|
|
||||||
|
|
@ -10,38 +10,43 @@ let buildType = config => {
|
||||||
globals: {
|
globals: {
|
||||||
three: "THREE"
|
three: "THREE"
|
||||||
},
|
},
|
||||||
output: [
|
output: [],
|
||||||
{
|
plugins: []
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (config.format) {
|
||||||
|
case "umd":
|
||||||
|
options.output.push({
|
||||||
format: "umd",
|
format: "umd",
|
||||||
name: "skinview3d",
|
name: "skinview3d",
|
||||||
file: `build/skinview3d${config.postfix}.js`
|
file: `build/skinview3d${config.postfix}.js`
|
||||||
},
|
});
|
||||||
{
|
break;
|
||||||
|
|
||||||
|
case "es":
|
||||||
|
options.output.push({
|
||||||
format: "es",
|
format: "es",
|
||||||
file: `build/skinview3d${config.postfix}.module.js`
|
file: `build/skinview3d${config.postfix}.js`
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw `Unknown format: ${config.format}`;
|
||||||
}
|
}
|
||||||
],
|
|
||||||
plugins: []
|
|
||||||
};
|
|
||||||
if (config.babel) {
|
if (config.babel) {
|
||||||
options.plugins.push(
|
options.plugins.push(
|
||||||
babel({
|
babel({
|
||||||
exclude: "node_modules/**",
|
exclude: "node_modules/**"
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.uglify) {
|
if (config.uglify) {
|
||||||
options.plugins.push(
|
options.plugins.push(
|
||||||
uglify({
|
uglify({
|
||||||
output: {
|
output: {
|
||||||
comments: (node, comment) => {
|
comments: "some"
|
||||||
let text = comment.value;
|
|
||||||
let type = comment.type;
|
|
||||||
if (type == "comment2") {
|
|
||||||
// multiline comment
|
|
||||||
return /@preserve|@license|@cc_on/i.test(text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, minify)
|
}, minify)
|
||||||
);
|
);
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
import { buildType } from "./rollup.common";
|
|
||||||
export default buildType({ postfix: ".babel", babel: true, uglify: false });
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
import { buildType } from "./rollup.common";
|
|
||||||
export default buildType({ postfix: ".babel.min", babel: true, uglify: true });
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
import { buildType } from "./rollup-util";
|
||||||
|
export default buildType({
|
||||||
|
postfix: "",
|
||||||
|
babel: true,
|
||||||
|
uglify: false,
|
||||||
|
format: "umd"
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
import { buildType } from "./rollup-util";
|
||||||
|
export default buildType({
|
||||||
|
postfix: ".min",
|
||||||
|
babel: true,
|
||||||
|
uglify: true,
|
||||||
|
format: "umd"
|
||||||
|
});
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
import { buildType } from "./rollup.common";
|
|
||||||
export default buildType({ postfix: "", babel: false, uglify: false });
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
import { buildType } from "./rollup.common";
|
|
||||||
export default buildType({ postfix: ".min", babel: false, uglify: true });
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
import { buildType } from "./rollup-util";
|
||||||
|
export default buildType({
|
||||||
|
postfix: ".module",
|
||||||
|
babel: false,
|
||||||
|
uglify: false,
|
||||||
|
format: "es"
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue