Skip to content

Commit 9a076b0

Browse files
committed
Update build script for browser
1 parent e88204d commit 9a076b0

File tree

5 files changed

+94
-46
lines changed

5 files changed

+94
-46
lines changed

.eslintrc.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es6": true,
5+
"node": true
6+
},
7+
"extends": "mdcs",
8+
"parserOptions": {
9+
"ecmaVersion": 2016,
10+
"sourceType": "module"
11+
},
12+
"rules": {
13+
"indent": [
14+
"error",
15+
"tab"
16+
],
17+
"linebreak-style": [
18+
"error",
19+
"unix"
20+
],
21+
"quotes": [
22+
"error",
23+
"single"
24+
],
25+
"semi": [
26+
"error",
27+
"always"
28+
]
29+
}
30+
}

examples/helloworld/helloworld.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
<script src="../lib/three.min.js"></script>
99
<script src="../lib/tween.min.js"></script>
10+
<script src="../lib/stats.min.js"></script>
1011
<script src="../lib/tf.min.js"></script>
1112
<script src="../lib/TrackballControls.js"></script>
1213
<script src="../../dist/tensorspace.js"></script>
@@ -82,4 +83,4 @@
8283
</script>
8384

8485
</body>
85-
</html>
86+
</html>

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"install": "^0.12.1",
2929
"npm": "^6.4.1",
3030
"three": "^0.98.0",
31-
"stats.js": "^0.17.0",
3231
"three-trackballcontrols": "^0.0.7"
3332
},
3433
"devDependencies": {
@@ -37,6 +36,8 @@
3736
"babel-core": "^6.26.0",
3837
"babel-preset-es2015": "^6.24.1",
3938
"chai": "^4.2.0",
39+
"eslint": "^5.13.0",
40+
"eslint-config-mdcs": "^4.2.3",
4041
"jasmine-core": "^3.3.0",
4142
"karma": "^3.1.4",
4243
"karma-chrome-launcher": "^2.2.0",
@@ -48,6 +49,7 @@
4849
"puppeteer": "^1.11.0",
4950
"rollup": "^0.66.0",
5051
"rollup-plugin-terser": "^4.0.1",
52+
"stats-js": "^1.0.0",
5153
"terser": "^3.14.1",
5254
"uglify-es": "^3.3.10",
5355
"yalc": "^1.0.0-pre.27"

rollup.config.npm.js

Lines changed: 56 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,64 +2,79 @@
22
* @author botime / https://github.com/botime
33
*/
44

5-
import { terser } from "rollup-plugin-terser";
5+
import { terser } from 'rollup-plugin-terser';
66

77
let terserOptions = {
88

9-
output: {
9+
output: {
1010

11-
ecma: 5,
12-
preamble: '// https://github.com/tensorspace-team/tensorspace/blob/master/LICENSE'
11+
ecma: 5,
12+
preamble: '// https://github.com/tensorspace-team/tensorspace/blob/master/LICENSE'
1313

14-
}
14+
}
1515

1616
};
1717

1818
export default [
1919

20-
// Build regular version for distribution
21-
{
22-
input: 'src/tensorspace.js',
23-
output: [ {
24-
25-
format: 'iife',
26-
file: 'dist/tensorspace.js',
27-
name: "TSP",
28-
sourcemap: true,
29-
30-
} ]
31-
32-
},
33-
3420
// Build regular version for development
3521
{
36-
37-
input: 'src/tensorspace.dev.js',
22+
external: [ 'three', '@tweenjs/tween.js', '@tensorflow/tfjs', 'three-trackballcontrols', 'stats-js' ],
23+
input: 'src/tensorspace.js',
3824
output: [ {
25+
globals: {
26+
'three': 'THREE',
27+
'@tweenjs/tween.js': 'TWEEN',
28+
'@tensorflow/tfjs': 'tf',
29+
'tensorspace': 'TSP',
30+
'stats-js': 'Stats',
31+
'three-trackballcontrols': 'THREE.TrackballControls'
32+
},
33+
format: 'iife',
34+
file: 'dist/tensorspace.js',
35+
name: 'TSP',
36+
sourcemap: true
3937

40-
format: 'esm',
41-
file: 'build/tensorspace.dev.esm.js',
42-
name: "TSP",
38+
}, {
39+
40+
format: 'cjs',
41+
file: 'dist/tensorspace.cjs.js',
42+
name: 'TSP',
4343
sourcemap: true
4444

4545
} ]
4646

4747
},
4848

49-
// Build minified version for distribution
50-
{
51-
52-
input: 'src/tensorspace.js',
53-
plugins: [ terser( terserOptions ) ],
54-
output: [ {
55-
56-
format: 'iife',
57-
file: 'dist/tensorspace.min.js',
58-
name: "TSP",
59-
sourcemap: true,
60-
61-
} ]
62-
63-
}
64-
65-
]
49+
// // Build regular version for development
50+
// {
51+
//
52+
// input: 'src/tensorspace.dev.js',
53+
// output: [ {
54+
//
55+
// format: 'esm',
56+
// file: 'build/tensorspace.dev.esm.js',
57+
// name: "TSP",
58+
// sourcemap: true
59+
//
60+
// } ]
61+
//
62+
// },
63+
//
64+
// // Build minified version for distribution
65+
// {
66+
//
67+
// input: 'src/tensorspace.js',
68+
// plugins: [ terser( terserOptions ) ],
69+
// output: [ {
70+
//
71+
// format: 'iife',
72+
// file: 'dist/tensorspace.min.js',
73+
// name: "TSP",
74+
// sourcemap: true,
75+
//
76+
// } ]
77+
//
78+
// }
79+
80+
];

src/scene/SceneInitializer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
import * as THREE from "three";
66
import * as TWEEN from "@tweenjs/tween.js";
7-
import Stats from "stats.js/src/Stats";
8-
import TrackballControls from "three-trackballcontrols";
7+
import * as Stats from "stats-js";
8+
import * as TrackballControls from "three-trackballcontrols";
99
import { DefaultCameraPos, DefaultLayerDepth } from "../utils/Constant";
1010

1111
function SceneInitializer( container ) {
@@ -232,4 +232,4 @@ SceneInitializer.prototype = {
232232

233233
};
234234

235-
export { SceneInitializer };
235+
export { SceneInitializer };

0 commit comments

Comments
 (0)