Skip to content

Commit f7adca0

Browse files
committed
Revert "删除多余的构建模板 (#177)"
This reverts commit dc29d2f.
1 parent dc29d2f commit f7adca0

55 files changed

Lines changed: 2119 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
require('./web-adapter');
2+
3+
<% if(polyfillsBundleFile) { %>
4+
// Polyfills bundle.
5+
require("<%= polyfillsBundleFile %>");
6+
<% } %>
7+
8+
// SystemJS support.
9+
window.self = window;
10+
require("<%= systemJsBundleFile %>");
11+
12+
const importMap = require("<%= importMapFile%>").default;
13+
System.warmup({
14+
importMap,
15+
importMapUrl: '<%= importMapFile%>',
16+
defaultHandler: (urlNoSchema) => {
17+
require('.' + urlNoSchema);
18+
},
19+
});
20+
21+
System.import('<%= applicationJs %>').then(({ Application }) => {
22+
return new Application();
23+
}).then((application) => {
24+
return onApplicationCreated(application);
25+
}).catch((err) => {
26+
console.error(err);
27+
});
28+
29+
function onApplicationCreated(application) {
30+
return System.import('cc').then((cc) => {
31+
require('./engine-adapter');
32+
return application.init(cc);
33+
}).then(() => application.start());
34+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"screenOrientation": "landscape",
3+
"networkTimeout": {
4+
"request": 5000,
5+
"connectSocket": 5000,
6+
"download": 500000,
7+
"upload": 5000
8+
},
9+
"showStatusBar": false
10+
}

templates/baidu-mini-game/game.ejs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
globalThis.__baiduRequire = require; // FIX: require implementation in browserify conflicts with baidu webpack
2+
require('./web-adapter');
3+
4+
<% if(polyfillsBundleFile) { %>
5+
// Polyfills bundle.
6+
require("<%= polyfillsBundleFile %>");
7+
<% } %>
8+
9+
// SystemJS support.
10+
require("<%= systemJsBundleFile %>");
11+
// 这句只有百度需要,因为百度的 webpack 提供了假的 System
12+
const System = globalThis.System;
13+
14+
// Adapt for IOS, swap if opposite
15+
if (canvas) {
16+
var _w = canvas.width;
17+
var _h = canvas.height;
18+
if (screen.width < screen.height) {
19+
if (canvas.width > canvas.height) {
20+
_w = canvas.height;
21+
_h = canvas.width;
22+
}
23+
} else {
24+
if (canvas.width < canvas.height) {
25+
_w = canvas.height;
26+
_h = canvas.width;
27+
}
28+
}
29+
canvas.width = _w;
30+
canvas.height = _h;
31+
}
32+
33+
// Adjust initial canvas size
34+
if (canvas && window.devicePixelRatio >= 2) {canvas.width *= 2; canvas.height *= 2;}
35+
36+
const importMap = require("<%= importMapFile%>").default;
37+
System.warmup({
38+
importMap,
39+
importMapUrl: '<%= importMapFile%>',
40+
defaultHandler: (urlNoSchema) => {
41+
require('.' + urlNoSchema);
42+
},
43+
});
44+
45+
System.import('<%= applicationJs %>').then(({ Application }) => {
46+
return new Application();
47+
}).then((application) => {
48+
return onApplicationCreated(application);
49+
}).catch((err) => {
50+
console.error(err);
51+
});
52+
53+
function onApplicationCreated(application) {
54+
return System.import('cc').then((cc) => {
55+
require('./engine-adapter');
56+
57+
// post system info to open data context
58+
swan.getOpenDataContext().postMessage({
59+
type: 'engine',
60+
event: 'systemInfo',
61+
systemInfo: swan.getSystemInfoSync(),
62+
});
63+
64+
return application.init(cc);
65+
}).then(() => application.start());
66+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"deviceOrientation": "landscape",
3+
"openDataContext": "",
4+
"networkTimeout":
5+
{
6+
"request": 5000,
7+
"connectSocket": 5000,
8+
"uploadFile": 5000,
9+
"downloadFile": 500000
10+
}
11+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"appid": "",
3+
"compileType": "game",
4+
"libVersion": "1.0.0",
5+
"bundle":
6+
{
7+
"exclude": ["node_moudules"],
8+
"entry": "game.js",
9+
"compilers": [
10+
{
11+
"type": "babel"
12+
}]
13+
}
14+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<% if (isUsePhysX) { %>
2+
const systemInfo = tt.getSystemInfoSync();
3+
// a hack way to load physics provide by bytedance
4+
if (tt.getPhysx) {
5+
tt.getPhysx({
6+
success (physx) {
7+
if (!physx) {
8+
console.error('can not use native PhysX');
9+
} else {
10+
console.info('physics plugin load success, version=' + physx.getVersion());
11+
GameGlobal.nativePhysX = physx;
12+
}
13+
loadCC();
14+
},
15+
fail () {
16+
loadCC();
17+
}
18+
});
19+
} else if (systemInfo.platform === 'android' && tt.getLoader && tt.getLoader()) {
20+
const appid = "<%= appid %>";
21+
const loader = tt.getLoader().loader;
22+
loader.load('physics', appid, "token", message => {
23+
if (message) {
24+
console.error('[tt.loader]:' + message);
25+
} else {
26+
console.info('[tt.loader]: physics plugin load success, version=' + tt.getPhy().getVersion());
27+
GameGlobal.nativePhysX = tt.getPhy();
28+
}
29+
loadCC();
30+
})
31+
} else {
32+
loadCC();
33+
}
34+
<% } %>
35+
36+
<% if (!isUsePhysX) { %>
37+
loadCC();
38+
<% } %>
39+
40+
function loadCC() {
41+
require('./web-adapter');
42+
43+
<% if(polyfillsBundleFile) { %>
44+
// Polyfills bundle.
45+
require("<%= polyfillsBundleFile %>");
46+
<% } %>
47+
48+
// SystemJS support.
49+
require("<%= systemJsBundleFile %>");
50+
51+
// Adapt for IOS, swap if opposite
52+
if (canvas){
53+
var _w = canvas.width;
54+
var _h = canvas.height;
55+
if (screen.width < screen.height) {
56+
if (canvas.width > canvas.height) {
57+
_w = canvas.height;
58+
_h = canvas.width;
59+
}
60+
} else {
61+
if (canvas.width < canvas.height) {
62+
_w = canvas.height;
63+
_h = canvas.width;
64+
}
65+
}
66+
canvas.width = _w;
67+
canvas.height = _h;
68+
}
69+
70+
// Adjust initial canvas size
71+
if (canvas && window.devicePixelRatio >= 2) {canvas.width *= 2; canvas.height *= 2;}
72+
73+
const importMap = require("<%= importMapFile%>").default;
74+
System.warmup({
75+
importMap,
76+
importMapUrl: '<%= importMapFile%>',
77+
defaultHandler: (urlNoSchema) => {
78+
require('.' + urlNoSchema);
79+
},
80+
handlers: {
81+
'plugin:': (urlNoSchema) => {
82+
typeof requirePlugin === 'function' ? requirePlugin(urlNoSchema) : require(urlNoSchema);
83+
},
84+
'project:': (urlNoSchema) => {
85+
require(urlNoSchema);
86+
},
87+
},
88+
});
89+
90+
System.import('<%= applicationJs %>').then(({ Application }) => {
91+
return new Application();
92+
}).then((application) => {
93+
return onApplicationCreated(application);
94+
}).catch((err) => {
95+
console.error(err);
96+
});
97+
98+
function onApplicationCreated(application) {
99+
return System.import('cc').then((cc) => {
100+
require('./engine-adapter');
101+
return application.init(cc);
102+
}).then(() => { return application.start(); });
103+
}
104+
105+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"deviceOrientation": "portrait",
3+
"showStatusBar": false,
4+
"openDataContext": "",
5+
"networkTimeout": {
6+
"request": 5000,
7+
"connectSocket": 5000,
8+
"uploadFile": 5000,
9+
"downloadFile": 500000
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"setting": {
3+
"urlCheck": true,
4+
"es6": false,
5+
"postcss": true,
6+
"minified": true,
7+
"newFeature": true
8+
},
9+
"appid": "testappId",
10+
"projectname": ""
11+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"instant_games": {
3+
"orientation": "PORTRAIT",
4+
"override_web_orientation": "PORTRAIT",
5+
"platform_version": "RICH_GAMEPLAY",
6+
"navigation_menu_version": "NAV_FLOATING"
7+
}
8+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<% if (webDebuggerSrc) { %>
2+
<script src="<%=webDebuggerSrc%>"></script>
3+
<script type="text/javascript">
4+
// open web debugger console
5+
window.VConsole && (window.vConsole = new VConsole());
6+
</script>
7+
<% } %>
8+
9+
<!-- Import fbinstant -->
10+
<!-- <script src="https://connect.facebook.net/en_US/fbinstant.6.3.js"></script> -->
11+
<script src="https://www.facebook.com/assets.php/en_US/fbinstant.latest.js"></script>
12+
13+
<!-- Polyfills bundle. -->
14+
<script src="<%= polyfillsBundleFile %>" charset="utf-8"> </script>
15+
16+
<!-- SystemJS support. -->
17+
<script src="<%= systemJsBundleFile %>" charset="utf-8"> </script>
18+
19+
<!-- Import map -->
20+
<script src="<%= importMapFile%>" type="systemjs-importmap" charset="utf-8"> </script>
21+
22+
<script>
23+
System.import('./<%= indexJsName %>').catch(function(err) { console.error(err); })
24+
</script>

0 commit comments

Comments
 (0)