Jump to content

es6 webpack adding phaser-spine plug in


ptotheaul
 Share

Recommended Posts

I am not great at web pack and can just not figure out how to get this plug in loaded.  I've looked at various threads about adding other plug ins and this is how I"m trying to do it based on those:

in webpack config I have:

// I add the path to the phaser spine pluggin

// Phaser webpack config
var phaserModule = path.join(__dirname, '/node_modules/phaser-ce/')
var phaser = path.join(phaserModule, 'build/custom/phaser-split.js')
var pixi = path.join(phaserModule, 'build/custom/pixi.js')
var p2 = path.join(phaserModule, 'build/custom/p2.js')
var phaserSpine = path.join(__dirname, '/src/external/phaser-spine.js');

 

//  I add it to the rules

 module: {
    rules: [
      { test: /\.js$/, use: ['babel-loader'], include: path.join(__dirname, 'src') },
      { test: /pixi\.js/, use: ['expose-loader?PIXI'] },
      { test: /phaser-split\.js$/, use: ['expose-loader?Phaser'] },
      { test: /p2\.js/, use: ['expose-loader?p2'] },
      { test: /phaser-spine\.js$/, use: ['expose-loader?PhaserSpine'] },

    ]
  },

// and I add the alias

resolve: {
    alias: {
      'phaser': phaser,
      'pixi': pixi,
      'p2': p2,
      'phaser-spine': phaserSpine,
    }
  }

 

In the boot state I have:

import Phaser from 'phaser';
import WebFont from 'webfontloader';
import PhaserSpine from 'phaser-spine';

export default class extends Phaser.State {
  init() {
          this.game.add.plugin(PhaserSpine.SpinePlugin);
  }

}

 

but this gives this error:

Uncaught TypeError: Cannot set property 'game' of undefined
    at 334.Phaser.PluginManager.add

 

I've tried so many different things but I can not get it to work.   Any insight would be very appreciated.

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...