LordLants Posted March 13, 2018 Share Posted March 13, 2018 Hi there. I am very partial to Angular, I use it for basically all of my personal projects and know that, in the long run, I would want to wrap any game that I make in an Angular shell eventually. Unfortunately, as far as I can tell, it is currently quite difficult to get Phaser 3 working with the Angular CLI due to two simple things: 1) if bundling with webpack (which Angular does by default) the .frag and .vert files need a raw-loader configuration, 2) the CANVAS_RENDERER and WEBGL_RENDERER need to be initialized. The Angular CLI does allow for these things by calling "ng eject" at the command line, adding module: { rules: [ { test: [ /\.vert$/, /\.frag$/ ], use: 'raw-loader' } ] }, plugins: [ new webpack.DefinePlugin({ 'CANVAS_RENDERER': JSON.stringify(true), 'WEBGL_RENDERER': JSON.stringify(true) }) ] but calling "ng eject" has its own set of adverse side effects that are not very ideal (you lose a lot of the CLI). Is there any way that these two small things can be handled so that Phaser 3 can easily be built and run in Angular without needing to use "ng eject"? Does anyone know of a way to currently use Phaser 3 with Angular without having to eject? Currently at any point if phaser.min.js is included as a script the bundler blows up, from all that I can tell. I know that part of the underlying problem is how the Angular CLI handles its webpack.config.js file in the first place, and how the CLI team doesn't want to allow more customization in the .angular-cli.json file, but that just kind of is what it is right now. Any feedback would be appreciated, thanks! Link to comment Share on other sites More sharing options...
bitm4ster Posted March 22, 2018 Share Posted March 22, 2018 ^this. i would like to know how to do this. i've been googling for hours with no luck :[ Link to comment Share on other sites More sharing options...
thunderpony Posted April 30, 2018 Share Posted April 30, 2018 I would like to know too. I can't get it to work without ejecting. Link to comment Share on other sites More sharing options...
LordLants Posted May 7, 2018 Author Share Posted May 7, 2018 Seems to be at a standstill. Was pointed out to me by bitm4ster that Phaser 3 at least supports typescript now, which is another fairly large "must" to use it in a framework that runs completely on Typescript. Link to comment Share on other sites More sharing options...
snowbillr Posted May 7, 2018 Share Posted May 7, 2018 Can you use a separate webpack config for the phaser bundle, and load that in via its own `<script>` tag? The main app's bundle and the game are very separate, there really isn't any need to go through pain to get them to bundle together. Link to comment Share on other sites More sharing options...
bitm4ster Posted May 7, 2018 Share Posted May 7, 2018 I managed to get it working by putting phaser.min.js in the assets directory. There's no intellisense but at least it works. Link to comment Share on other sites More sharing options...
Recommended Posts