Skip to content

Commit 72ac4a1

Browse files
committed
Added new FB build configs
1 parent a938003 commit 72ac4a1

6 files changed

Lines changed: 110 additions & 35 deletions

File tree

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
"help": "node scripts/help.js",
2020
"build": "webpack",
2121
"watch": "webpack --watch",
22+
"buildfb": "webpack --config webpack.fb.config.js",
23+
"watchfb": "webpack --config webpack.fb.config.js --watch",
2224
"dist": "webpack --config webpack.dist.config.js",
25+
"distfb": "webpack --config webpack.fb.dist.config.js",
26+
"distfull": "npm run dist && npm run distfb",
2327
"plugin.cam3d": "webpack --config plugins/camera3d/webpack.config.js",
2428
"lint": "eslint --config .eslintrc.json \"src/**/*.js\"",
2529
"lintfix": "eslint --config .eslintrc.json \"src/**/*.js\" --fix",

scripts/copy-to-examples-fb.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
let fs = require('fs-extra');
2+
3+
// let dest = '../phaser3-examples/public/build/dev.js';
4+
// let destMap = '../phaser3-examples/public/build/phaser.js.map';
5+
6+
let source = './build/phaser-facebook-instant-games.js';
7+
let sourceMap = './build/phaser-facebook-instant-games.js.map';
8+
let dest = '../fbtest1/lib/dev.js';
9+
let destMap = '../fbtest1/lib/phaser.js.map';
10+
11+
if (fs.existsSync(dest))
12+
{
13+
fs.copy(sourceMap, destMap, function (err) {
14+
15+
if (err)
16+
{
17+
return console.error(err);
18+
}
19+
20+
});
21+
22+
fs.copy(source, dest, function (err) {
23+
24+
if (err)
25+
{
26+
return console.error(err);
27+
}
28+
29+
console.log('Build copied to ' + dest);
30+
31+
});
32+
}
33+
else
34+
{
35+
// console.log('Copy-to-Examples failed: Phaser 3 Examples not present at ../phaser3-examples');
36+
}

scripts/copy-to-examples.js

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ let source = './build/phaser.js';
55
let sourceMap = './build/phaser.js.map';
66
let dest = '../phaser3-examples/public/build/dev.js';
77
let destMap = '../phaser3-examples/public/build/phaser.js.map';
8+
9+
let sourceFB = './build/phaser-facebook-instant-games.js';
10+
let sourceFBMap = './build/phaser-facebook-instant-games.js.map';
811
let destFB = '../fbtest1/lib/dev.js';
912
let destFBMap = '../fbtest1/lib/phaser.js.map';
1013

11-
let sourceCore = './build/phaser-core.js';
12-
let sourceMapCore = './build/phaser-core.js.map';
13-
let destCore = '../phaser3-examples/public/build/phaser-core.js';
14-
let destMapCore = '../phaser3-examples/public/build/phaser-core.js.map';
15-
14+
/*
1615
if (fs.existsSync(destFB))
1716
{
1817
fs.copy(source, destFB, function (err) {
@@ -35,29 +34,10 @@ if (fs.existsSync(destFB))
3534
3635
});
3736
}
37+
*/
3838

3939
if (fs.existsSync(dest))
4040
{
41-
fs.copy(sourceMapCore, destMapCore, function (err) {
42-
43-
if (err)
44-
{
45-
return console.error(err);
46-
}
47-
48-
});
49-
50-
fs.copy(sourceCore, destCore, function (err) {
51-
52-
if (err)
53-
{
54-
return console.error(err);
55-
}
56-
57-
console.log('Build copied to ' + destCore);
58-
59-
});
60-
6141
fs.copy(sourceMap, destMap, function (err) {
6242

6343
if (err)
@@ -89,5 +69,5 @@ if (fs.existsSync(dest))
8969
}
9070
else
9171
{
92-
console.log('Copy-to-Examples failed: Phaser 3 Examples not present at ../phaser3-examples');
72+
// console.log('Copy-to-Examples failed: Phaser 3 Examples not present at ../phaser3-examples');
9373
}

webpack.dist.config.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ module.exports = {
1414
'phaser.min': './phaser.js',
1515
'phaser-arcade-physics': './phaser-arcade-physics.js',
1616
'phaser-arcade-physics.min': './phaser-arcade-physics.js',
17-
'phaser-core': './phaser-core.js',
18-
'phaser-core.min': './phaser-core.js'
17+
'phaser-facebook-instant-games': './phaser-facebook-instant-games.js',
18+
'phaser-facebook-instant-games.min': './phaser-facebook-instant-games.js'
1919
},
2020

2121
output: {
@@ -51,8 +51,7 @@ module.exports = {
5151
"typeof CANVAS_RENDERER": JSON.stringify(true),
5252
"typeof WEBGL_RENDERER": JSON.stringify(true),
5353
"typeof EXPERIMENTAL": JSON.stringify(false),
54-
"typeof PLUGIN_CAMERA3D": JSON.stringify(false),
55-
"typeof PLUGIN_FBINSTANT": JSON.stringify(false)
54+
"typeof PLUGIN_CAMERA3D": JSON.stringify(false)
5655
}),
5756

5857
new CleanWebpackPlugin([ 'dist' ])

webpack.fb.config.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
'use strict';
2+
3+
const webpack = require('webpack');
4+
const exec = require('child_process').exec;
5+
6+
module.exports = {
7+
mode: 'development',
8+
9+
context: `${__dirname}/src/`,
10+
11+
entry: {
12+
phaser: './phaser.js'
13+
},
14+
15+
output: {
16+
path: `${__dirname}/build/`,
17+
filename: 'phaser-facebook-instant-games.js',
18+
library: 'Phaser',
19+
libraryTarget: 'umd',
20+
sourceMapFilename: '[file].map',
21+
devtoolModuleFilenameTemplate: 'webpack:///[resource-path]', // string
22+
devtoolFallbackModuleFilenameTemplate: 'webpack:///[resource-path]?[hash]', // string
23+
umdNamedDefine: true
24+
},
25+
26+
performance: { hints: false },
27+
28+
plugins: [
29+
new webpack.DefinePlugin({
30+
"typeof CANVAS_RENDERER": JSON.stringify(true),
31+
"typeof WEBGL_RENDERER": JSON.stringify(true),
32+
"typeof EXPERIMENTAL": JSON.stringify(false),
33+
"typeof PLUGIN_CAMERA3D": JSON.stringify(false),
34+
"typeof PLUGIN_FBINSTANT": JSON.stringify(true)
35+
}),
36+
{
37+
apply: (compiler) => {
38+
compiler.hooks.afterEmit.tap('AfterEmitPlugin', (compilation) => {
39+
exec('node scripts/copy-to-examples-fb.js', (err, stdout, stderr) => {
40+
if (stdout) process.stdout.write(stdout);
41+
if (stderr) process.stderr.write(stderr);
42+
});
43+
});
44+
}
45+
}
46+
],
47+
48+
devtool: 'source-map'
49+
};
Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@ module.exports = {
1010
context: `${__dirname}/src/`,
1111

1212
entry: {
13-
camera3d: './FacebookInstantGamesPlugin.js',
14-
'camera3d.min': './FacebookInstantGamesPlugin.js'
13+
'phaser-facebook-instant-games': './phaser-facebook-instant-games.js',
14+
'phaser-facebook-instant-games.min': './phaser-facebook-instant-games.js'
1515
},
1616

1717
output: {
1818
path: `${__dirname}/dist/`,
1919
filename: '[name].js',
20-
library: 'FacebookInstantGamesPlugin',
21-
libraryTarget: 'var'
20+
library: 'Phaser',
21+
libraryTarget: 'umd',
22+
umdNamedDefine: true
2223
},
2324

2425
performance: { hints: false },
@@ -42,6 +43,12 @@ module.exports = {
4243
},
4344

4445
plugins: [
45-
new CleanWebpackPlugin([ 'dist' ])
46+
new webpack.DefinePlugin({
47+
"typeof CANVAS_RENDERER": JSON.stringify(true),
48+
"typeof WEBGL_RENDERER": JSON.stringify(true),
49+
"typeof EXPERIMENTAL": JSON.stringify(false),
50+
"typeof PLUGIN_CAMERA3D": JSON.stringify(false),
51+
"typeof PLUGIN_FBINSTANT": JSON.stringify(true)
52+
})
4653
]
4754
};

0 commit comments

Comments
 (0)