Skip to content

Commit

Permalink
Fix issue with VueJS using expose-loader
Browse files Browse the repository at this point in the history
  • Loading branch information
jdnichollsc committed Mar 15, 2021
1 parent 0f6e45f commit bd6c582
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
4 changes: 2 additions & 2 deletions demo-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dependencies": {
"core-js": "^3.0.0",
"vue": "^2.6.10",
"phaser-ce": "2.13.3",
"phaser-ce": "2.16.2",
"@ion-phaser-ce/core": "^1.0.4"
},
"devDependencies": {
Expand All @@ -20,7 +20,7 @@
"babel-eslint": "^10.0.1",
"eslint": "^7.0.0",
"eslint-plugin-vue": "^7.0.0",
"expose-loader": "^2.0.0",
"expose-loader": "^1.0.0",
"vue-template-compiler": "^2.6.10"
},
"postcss": {
Expand Down
2 changes: 1 addition & 1 deletion demo-vue/src/main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Vue from 'vue'
import 'pixi'
import 'p2'
import 'phaser'
import Vue from 'vue'
import { defineCustomElements as defineIonPhaser } from '@ion-phaser-ce/core/loader'

import App from './App.vue'
Expand Down
42 changes: 25 additions & 17 deletions demo-vue/vue.config.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,48 @@
var path = require('path')

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')

module.exports = {
chainWebpack: config => {
chainWebpack: (config) => {
config.resolve
.extensions
.merge(['.mjs', '.js', '.jsx', '.vue', '.json', '.wasm'])
.end()
.alias
.set('phaser', phaser)
.set('pixi', pixi)
.set('p2', p2);
.set('phaser', 'phaser-ce/build/custom/phaser-split.js')
.set('pixi', 'phaser-ce/build/custom/pixi.js')
.set('p2', 'phaser-ce/build/custom/p2.js')

config.module
.rule('phaser')
.test(/phaser-split\.js$/)
.use('expose-loader?Phaser')
.loader('expose-loader?Phaser')
.loader('expose-loader')
.options({
exposes: {
globalName: "Phaser",
override: true,
}
})
.end()

config.module
.rule('pixi')
.test(/pixi\.js$/)
.use('expose-loader?PIXI')
.loader('expose-loader?PIXI')
.loader('expose-loader')
.options({
exposes: {
globalName: "PIXI",
override: true,
}
})
.end()

config.module
.rule('p2')
.test(/p2\.js$/)
.use('expose-loader?p2')
.loader('expose-loader?p2')
.loader('expose-loader')
.options({
exposes: {
globalName: "p2",
override: true,
}
})
.end()
}
}

0 comments on commit bd6c582

Please sign in to comment.