Last active
April 12, 2020 18:13
-
-
Save jvanderbiest/6a34ab35f8ff90107642561a697a3f13 to your computer and use it in GitHub Desktop.
Cordova webpack default configuration file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as Phaser from 'phaser'; | |
import IntroScene from './scenes/intro.scene'; | |
export class PhaserGame { | |
gameConfig = { | |
type: Phaser.AUTO, | |
width: 800, | |
height: 600, | |
physics: { | |
default: 'arcade', | |
arcade: { | |
gravity: { y: 200 } | |
} | |
}, | |
scene: [IntroScene] | |
} | |
constructor() { | |
debugger; | |
new Phaser.Game(this.gameConfig) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class IntroScene extends Phaser.Scene | |
{ | |
constructor() | |
{ | |
super('instro-scene') | |
} | |
preload() | |
{ | |
} | |
create() | |
{ | |
this.add.text(200, 50, "Hello from Phaser running in Cordova"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { PhaserGame} from './bootstrap'; | |
/* | |
* Licensed to the Apache Software Foundation (ASF) under one | |
* or more contributor license agreements. See the NOTICE file | |
* distributed with this work for additional information | |
* regarding copyright ownership. The ASF licenses this file | |
* to you under the Apache License, Version 2.0 (the | |
* "License"); you may not use this file except in compliance | |
* with the License. You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, | |
* software distributed under the License is distributed on an | |
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
* KIND, either express or implied. See the License for the | |
* specific language governing permissions and limitations | |
* under the License. | |
*/ | |
var app = { | |
// Application Constructor | |
initialize: function() { | |
document.addEventListener('deviceready', this.onDeviceReady.bind(this), false); | |
}, | |
// deviceready Event Handler | |
// | |
// Bind any cordova events here. Common events are: | |
// 'pause', 'resume', etc. | |
onDeviceReady: function() { | |
debugger; | |
new PhaserGame(); | |
this.receivedEvent('deviceready'); | |
} | |
}; | |
app.initialize(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"target": "es5", | |
"sourceMap": true | |
}, | |
"include": [ | |
"**/*.ts" | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const webpack = require('webpack'); | |
module.exports = { | |
mode: 'development', | |
entry: { | |
app: './src/main.ts', | |
vendors: ['phaser'] | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.tsx?$/, | |
use: 'ts-loader', | |
exclude: /node_modules/ | |
} | |
] | |
}, | |
resolve: { | |
extensions: [ '.ts', '.tsx', '.js' ] | |
}, | |
output: { | |
filename: 'app.bundle.js', | |
path: path.resolve(__dirname, 'www'), | |
}, | |
devServer: { | |
contentBase: path.resolve(__dirname, 'www'), | |
host: 'localhost', | |
https: true | |
}, | |
devtool: 'inline-source-map', | |
plugins: [ | |
new webpack.DefinePlugin({ | |
'typeof CANVAS_RENDERER': JSON.stringify(true), | |
'typeof WEBGL_RENDERER': JSON.stringify(true) | |
}), | |
], | |
optimization: { | |
splitChunks: { | |
cacheGroups: { | |
commons: { | |
test: /[\\/]node_modules[\\/]/, | |
name: 'vendors', | |
chunks: 'all' | |
} | |
} | |
} | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
module.exports = { | |
mode: 'development', | |
entry: './src/index.js', | |
output: { | |
path: path.resolve(__dirname, 'www'), | |
filename: 'app.bundle.js', | |
}, | |
devServer: { | |
contentBase: path.resolve(__dirname, 'www'), | |
host: 'localhost', | |
https: true | |
}, | |
devtool: 'inline-source-map', | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment