Added webpack shell script to copy build file to examples.

This commit is contained in:
Richard Davey 2016-11-24 01:35:02 +00:00
parent 98c932e7c4
commit 13f49f6086
7 changed files with 128 additions and 16 deletions

15
v3/copy-to-examples.js Normal file
View file

@ -0,0 +1,15 @@
var fs = require('fs-extra');
var source = './dist/phaser.js';
var dest = '../../phaser3-examples/public/js/phaser.js';
fs.copy(source, dest, function (err) {
if (err)
{
return console.error(err);
}
console.log('Copied to ' + dest);
});

View file

@ -33,6 +33,9 @@
"webpack": "2.1.0-beta.27"
},
"devDependencies": {
"webpack-dev-server": "2.1.0-beta.11"
"copy-webpack-plugin": "^4.0.1",
"fs-extra": "^1.0.0",
"webpack-dev-server": "2.1.0-beta.11",
"webpack-shell-plugin": "^0.4.3"
}
}

19
v3/src/boot/Config.js Normal file
View file

@ -0,0 +1,19 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
// var CONST = require('../const');
function Config (config)
{
if (config === undefined) { config = {}; }
this.renderType = config.renderType || 0;
this.gameTitle = config.game || 'bomberman';
}
Config.prototype.constructor = Config;
module.exports = Config;

View file

@ -6,14 +6,16 @@
var CONST = require('../const');
var DebugHeader = function (renderType, ie)
var DebugHeader = function (config)
{
var c = (renderType === CONST.CANVAS) ? 'Canvas' : 'WebGL';
var c = (config.renderType === CONST.CANVAS) ? 'Canvas' : 'WebGL';
var ie = false;
if (!ie)
{
var args = [
'%c %c %c %c %c Phaser v' + CONST.VERSION + ' / ' + c + ' %c http://phaser.io',
'%c %c %c %c %c ' + config.gameTitle + ' / Phaser v' + CONST.VERSION + ' / ' + c + ' %c http://phaser.io',
'background: #ff0000',
'background: #ffff00',
'background: #00ff00',

View file

@ -4,11 +4,14 @@
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var Config = require('./Config');
var DebugHeader = require('./DebugHeader');
var Game = function ()
var Game = function (config)
{
DebugHeader(0);
this.config = new Config(config);
DebugHeader(this.config);
};
module.exports = Game;

View file

@ -1,6 +1,7 @@
'use strict';
const webpack = require('webpack');
const WebpackShellPlugin = require('webpack-shell-plugin');
module.exports = {
@ -13,12 +14,14 @@ module.exports = {
output: {
path: './dist',
filename: '[name].js',
library: 'Phaser',
publicPath: '/lib'
library: 'Phaser'
},
devServer: {
contentBase: '/src'
}
plugins: [
new WebpackShellPlugin({
onBuildEnd: 'node copy-to-examples.js'
})
]
};

View file

@ -182,6 +182,10 @@ block-stream@*:
dependencies:
inherits "~2.0.0"
bluebird@^2.10.2:
version "2.11.0"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-2.11.0.tgz#534b9033c022c9579c56ba3b3e5a5caafbb650e1"
bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.4.0:
version "4.11.6"
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.6.tgz#53344adb14617a13f6e8dd2ce28905d1c0ba3215"
@ -427,6 +431,19 @@ cookie@0.3.1:
version "0.3.1"
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb"
copy-webpack-plugin@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/copy-webpack-plugin/-/copy-webpack-plugin-4.0.1.tgz#9728e383b94316050d0c7463958f2b85c0aa8200"
dependencies:
bluebird "^2.10.2"
fs-extra "^0.26.4"
glob "^6.0.4"
is-glob "^3.1.0"
loader-utils "^0.2.15"
lodash "^4.3.0"
minimatch "^3.0.0"
node-dir "^0.1.10"
core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
@ -744,6 +761,24 @@ fresh@0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.3.0.tgz#651f838e22424e7566de161d8358caa199f83d4f"
fs-extra@^0.26.4:
version "0.26.7"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-0.26.7.tgz#9ae1fdd94897798edab76d0918cf42d0c3184fa9"
dependencies:
graceful-fs "^4.1.2"
jsonfile "^2.1.0"
klaw "^1.0.0"
path-is-absolute "^1.0.0"
rimraf "^2.2.8"
fs-extra@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-1.0.0.tgz#cd3ce5f7e7cb6145883fcae3191e9877f8587950"
dependencies:
graceful-fs "^4.1.2"
jsonfile "^2.1.0"
klaw "^1.0.0"
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
@ -819,6 +854,16 @@ glob-parent@^2.0.0:
dependencies:
is-glob "^2.0.0"
glob@^6.0.4:
version "6.0.4"
resolved "https://registry.yarnpkg.com/glob/-/glob-6.0.4.tgz#0f08860f6a155127b2fadd4f9ce24b1aab6e4d22"
dependencies:
inflight "^1.0.4"
inherits "2"
minimatch "2 || 3"
once "^1.3.0"
path-is-absolute "^1.0.0"
glob@^7.0.5:
version "7.1.1"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8"
@ -830,7 +875,7 @@ glob@^7.0.5:
once "^1.3.0"
path-is-absolute "^1.0.0"
graceful-fs@^4.1.2:
graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9:
version "4.1.10"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.10.tgz#f2d720c22092f743228775c75e3612632501f131"
@ -1041,7 +1086,7 @@ is-glob@^2.0.0, is-glob@^2.0.1:
dependencies:
is-extglob "^1.0.0"
is-glob@^3.0.0:
is-glob@^3.0.0, is-glob@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-3.1.0.tgz#7ba5ae24217804ac70707b96922567486cc3e84a"
dependencies:
@ -1128,6 +1173,12 @@ json5@^0.5.0:
version "0.5.0"
resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.0.tgz#9b20715b026cbe3778fd769edccd822d8332a5b2"
jsonfile@^2.1.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8"
optionalDependencies:
graceful-fs "^4.1.6"
jsonify@~0.0.0:
version "0.0.0"
resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73"
@ -1150,6 +1201,12 @@ kind-of@^3.0.2:
dependencies:
is-buffer "^1.0.2"
klaw@^1.0.0:
version "1.3.1"
resolved "https://registry.yarnpkg.com/klaw/-/klaw-1.3.1.tgz#4088433b46b3b1ba259d78785d8e96f73ba02439"
optionalDependencies:
graceful-fs "^4.1.9"
lazy-cache@^1.0.3:
version "1.0.4"
resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e"
@ -1174,7 +1231,7 @@ loader-runner@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-2.2.0.tgz#824c1b699c4e7a2b6501b85902d5b862bf45b3fa"
loader-utils@^0.2.16:
loader-utils@^0.2.15, loader-utils@^0.2.16:
version "0.2.16"
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-0.2.16.tgz#f08632066ed8282835dff88dfb52704765adee6d"
dependencies:
@ -1253,7 +1310,7 @@ minimalistic-assert@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.0.tgz#702be2dda6b37f4836bcb3f5db56641b64a1d3d3"
minimatch@^3.0.0, minimatch@^3.0.2:
"minimatch@2 || 3", minimatch@^3.0.0, minimatch@^3.0.2:
version "3.0.3"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774"
dependencies:
@ -1285,6 +1342,12 @@ negotiator@0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9"
node-dir@^0.1.10:
version "0.1.16"
resolved "https://registry.yarnpkg.com/node-dir/-/node-dir-0.1.16.tgz#d2ef583aa50b90d93db8cdd26fcea58353957fe4"
dependencies:
minimatch "^3.0.2"
node-libs-browser@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/node-libs-browser/-/node-libs-browser-1.0.0.tgz#ff8ad6c2cfa78043bdd0091ec07f0aaa581620fc"
@ -1695,7 +1758,7 @@ right-align@^0.1.1:
dependencies:
align-text "^0.1.1"
rimraf@2, rimraf@~2.5.1, rimraf@~2.5.4:
rimraf@2, rimraf@^2.2.8, rimraf@~2.5.1, rimraf@~2.5.4:
version "2.5.4"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.5.4.tgz#96800093cbf1a0c86bd95b4625467535c29dfa04"
dependencies:
@ -2094,6 +2157,10 @@ webpack-dev-server@2.1.0-beta.11:
webpack-dev-middleware "^1.4.0"
yargs "^6.0.0"
webpack-shell-plugin@^0.4.3:
version "0.4.3"
resolved "https://registry.yarnpkg.com/webpack-shell-plugin/-/webpack-shell-plugin-0.4.3.tgz#a633e98c16b3bed5b6963e98059ca783841f3043"
webpack-sources@^0.1.0:
version "0.1.3"
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-0.1.3.tgz#15ce2fb79d0a1da727444ba7c757bf164294f310"