mirror of
https://github.com/photonstorm/phaser
synced 2024-11-21 20:23:19 +00:00
Added new FB build configs
This commit is contained in:
parent
a9380034a5
commit
72ac4a1cda
6 changed files with 110 additions and 35 deletions
|
@ -19,7 +19,11 @@
|
|||
"help": "node scripts/help.js",
|
||||
"build": "webpack",
|
||||
"watch": "webpack --watch",
|
||||
"buildfb": "webpack --config webpack.fb.config.js",
|
||||
"watchfb": "webpack --config webpack.fb.config.js --watch",
|
||||
"dist": "webpack --config webpack.dist.config.js",
|
||||
"distfb": "webpack --config webpack.fb.dist.config.js",
|
||||
"distfull": "npm run dist && npm run distfb",
|
||||
"plugin.cam3d": "webpack --config plugins/camera3d/webpack.config.js",
|
||||
"lint": "eslint --config .eslintrc.json \"src/**/*.js\"",
|
||||
"lintfix": "eslint --config .eslintrc.json \"src/**/*.js\" --fix",
|
||||
|
|
36
scripts/copy-to-examples-fb.js
Normal file
36
scripts/copy-to-examples-fb.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
let fs = require('fs-extra');
|
||||
|
||||
// let dest = '../phaser3-examples/public/build/dev.js';
|
||||
// let destMap = '../phaser3-examples/public/build/phaser.js.map';
|
||||
|
||||
let source = './build/phaser-facebook-instant-games.js';
|
||||
let sourceMap = './build/phaser-facebook-instant-games.js.map';
|
||||
let dest = '../fbtest1/lib/dev.js';
|
||||
let destMap = '../fbtest1/lib/phaser.js.map';
|
||||
|
||||
if (fs.existsSync(dest))
|
||||
{
|
||||
fs.copy(sourceMap, destMap, function (err) {
|
||||
|
||||
if (err)
|
||||
{
|
||||
return console.error(err);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
fs.copy(source, dest, function (err) {
|
||||
|
||||
if (err)
|
||||
{
|
||||
return console.error(err);
|
||||
}
|
||||
|
||||
console.log('Build copied to ' + dest);
|
||||
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
// console.log('Copy-to-Examples failed: Phaser 3 Examples not present at ../phaser3-examples');
|
||||
}
|
|
@ -5,14 +5,13 @@ let source = './build/phaser.js';
|
|||
let sourceMap = './build/phaser.js.map';
|
||||
let dest = '../phaser3-examples/public/build/dev.js';
|
||||
let destMap = '../phaser3-examples/public/build/phaser.js.map';
|
||||
|
||||
let sourceFB = './build/phaser-facebook-instant-games.js';
|
||||
let sourceFBMap = './build/phaser-facebook-instant-games.js.map';
|
||||
let destFB = '../fbtest1/lib/dev.js';
|
||||
let destFBMap = '../fbtest1/lib/phaser.js.map';
|
||||
|
||||
let sourceCore = './build/phaser-core.js';
|
||||
let sourceMapCore = './build/phaser-core.js.map';
|
||||
let destCore = '../phaser3-examples/public/build/phaser-core.js';
|
||||
let destMapCore = '../phaser3-examples/public/build/phaser-core.js.map';
|
||||
|
||||
/*
|
||||
if (fs.existsSync(destFB))
|
||||
{
|
||||
fs.copy(source, destFB, function (err) {
|
||||
|
@ -35,29 +34,10 @@ if (fs.existsSync(destFB))
|
|||
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
||||
if (fs.existsSync(dest))
|
||||
{
|
||||
fs.copy(sourceMapCore, destMapCore, function (err) {
|
||||
|
||||
if (err)
|
||||
{
|
||||
return console.error(err);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
fs.copy(sourceCore, destCore, function (err) {
|
||||
|
||||
if (err)
|
||||
{
|
||||
return console.error(err);
|
||||
}
|
||||
|
||||
console.log('Build copied to ' + destCore);
|
||||
|
||||
});
|
||||
|
||||
fs.copy(sourceMap, destMap, function (err) {
|
||||
|
||||
if (err)
|
||||
|
@ -89,5 +69,5 @@ if (fs.existsSync(dest))
|
|||
}
|
||||
else
|
||||
{
|
||||
console.log('Copy-to-Examples failed: Phaser 3 Examples not present at ../phaser3-examples');
|
||||
// console.log('Copy-to-Examples failed: Phaser 3 Examples not present at ../phaser3-examples');
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@ module.exports = {
|
|||
'phaser.min': './phaser.js',
|
||||
'phaser-arcade-physics': './phaser-arcade-physics.js',
|
||||
'phaser-arcade-physics.min': './phaser-arcade-physics.js',
|
||||
'phaser-core': './phaser-core.js',
|
||||
'phaser-core.min': './phaser-core.js'
|
||||
'phaser-facebook-instant-games': './phaser-facebook-instant-games.js',
|
||||
'phaser-facebook-instant-games.min': './phaser-facebook-instant-games.js'
|
||||
},
|
||||
|
||||
output: {
|
||||
|
@ -51,8 +51,7 @@ module.exports = {
|
|||
"typeof CANVAS_RENDERER": JSON.stringify(true),
|
||||
"typeof WEBGL_RENDERER": JSON.stringify(true),
|
||||
"typeof EXPERIMENTAL": JSON.stringify(false),
|
||||
"typeof PLUGIN_CAMERA3D": JSON.stringify(false),
|
||||
"typeof PLUGIN_FBINSTANT": JSON.stringify(false)
|
||||
"typeof PLUGIN_CAMERA3D": JSON.stringify(false)
|
||||
}),
|
||||
|
||||
new CleanWebpackPlugin([ 'dist' ])
|
||||
|
|
49
webpack.fb.config.js
Normal file
49
webpack.fb.config.js
Normal file
|
@ -0,0 +1,49 @@
|
|||
'use strict';
|
||||
|
||||
const webpack = require('webpack');
|
||||
const exec = require('child_process').exec;
|
||||
|
||||
module.exports = {
|
||||
mode: 'development',
|
||||
|
||||
context: `${__dirname}/src/`,
|
||||
|
||||
entry: {
|
||||
phaser: './phaser.js'
|
||||
},
|
||||
|
||||
output: {
|
||||
path: `${__dirname}/build/`,
|
||||
filename: 'phaser-facebook-instant-games.js',
|
||||
library: 'Phaser',
|
||||
libraryTarget: 'umd',
|
||||
sourceMapFilename: '[file].map',
|
||||
devtoolModuleFilenameTemplate: 'webpack:///[resource-path]', // string
|
||||
devtoolFallbackModuleFilenameTemplate: 'webpack:///[resource-path]?[hash]', // string
|
||||
umdNamedDefine: true
|
||||
},
|
||||
|
||||
performance: { hints: false },
|
||||
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
"typeof CANVAS_RENDERER": JSON.stringify(true),
|
||||
"typeof WEBGL_RENDERER": JSON.stringify(true),
|
||||
"typeof EXPERIMENTAL": JSON.stringify(false),
|
||||
"typeof PLUGIN_CAMERA3D": JSON.stringify(false),
|
||||
"typeof PLUGIN_FBINSTANT": JSON.stringify(true)
|
||||
}),
|
||||
{
|
||||
apply: (compiler) => {
|
||||
compiler.hooks.afterEmit.tap('AfterEmitPlugin', (compilation) => {
|
||||
exec('node scripts/copy-to-examples-fb.js', (err, stdout, stderr) => {
|
||||
if (stdout) process.stdout.write(stdout);
|
||||
if (stderr) process.stderr.write(stderr);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
devtool: 'source-map'
|
||||
};
|
|
@ -10,15 +10,16 @@ module.exports = {
|
|||
context: `${__dirname}/src/`,
|
||||
|
||||
entry: {
|
||||
camera3d: './FacebookInstantGamesPlugin.js',
|
||||
'camera3d.min': './FacebookInstantGamesPlugin.js'
|
||||
'phaser-facebook-instant-games': './phaser-facebook-instant-games.js',
|
||||
'phaser-facebook-instant-games.min': './phaser-facebook-instant-games.js'
|
||||
},
|
||||
|
||||
output: {
|
||||
path: `${__dirname}/dist/`,
|
||||
filename: '[name].js',
|
||||
library: 'FacebookInstantGamesPlugin',
|
||||
libraryTarget: 'var'
|
||||
library: 'Phaser',
|
||||
libraryTarget: 'umd',
|
||||
umdNamedDefine: true
|
||||
},
|
||||
|
||||
performance: { hints: false },
|
||||
|
@ -42,6 +43,12 @@ module.exports = {
|
|||
},
|
||||
|
||||
plugins: [
|
||||
new CleanWebpackPlugin([ 'dist' ])
|
||||
new webpack.DefinePlugin({
|
||||
"typeof CANVAS_RENDERER": JSON.stringify(true),
|
||||
"typeof WEBGL_RENDERER": JSON.stringify(true),
|
||||
"typeof EXPERIMENTAL": JSON.stringify(false),
|
||||
"typeof PLUGIN_CAMERA3D": JSON.stringify(false),
|
||||
"typeof PLUGIN_FBINSTANT": JSON.stringify(true)
|
||||
})
|
||||
]
|
||||
};
|
Loading…
Reference in a new issue