Webpack 参考错误:未定义相位器

Webpack 参考错误:未定义相位器,webpack,phaser-framework,Webpack,Phaser Framework,我有这个src/index.html文件: <!doctype html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>Making your first Phaser 3 Game - Part 1</title> <script src="//cdn.jsdelivr.net/npm/phaser@3.11.0

我有这个src/index.html文件:

    <!doctype html> 
<html lang="en"> 
<head> 
    <meta charset="UTF-8" />
    <title>Making your first Phaser 3 Game - Part 1</title>
    <script src="//cdn.jsdelivr.net/npm/phaser@3.11.0/dist/phaser.js"></script>
    <style type="text/css">
        body {
            margin: 0;
        }
    </style>
</head>
<body>
<script type="text/javascript">

    var config = {
        type: Phaser.AUTO,
        width: 800,
        height: 600,
        scene: {
            preload: preload,
            create: create,
            update: update
        }
    };

    var game = new Phaser.Game(config);

    function preload ()    
    {
        this.load.image('sky', 'assets/sky.png');
        this.load.image('ground', 'assets/platform.png');
        this.load.image('star', 'assets/star.png');
        this.load.image('bomb', 'assets/bomb.png');
        this.load.spritesheet('dude', 
            'assets/dude.png',
            { frameWidth: 32, frameHeight: 48 }
    );
    }

    function create ()
    {
        this.add.image(400, 300, 'sky');
    }

    function update ()
    {
    }

</script>

</body>
</html>
当我在项目根目录中时,键入:

  npx webpack --mode development
它在项目的根目录中创建一个dist/index.html文件

我用我的网络浏览器(firefox)打开文件,得到这个输出

它无法识别index.html文件中的“Phaser”命令

检查index.html文件中的这一行:

var game = new Phaser.Game(config);
发生什么事了?我怎样才能解决这个问题?如果你需要更多的信息,只要问我,我会扩展,所以你可以帮助


是我在提问时正在处理的功能分支中的存储库

从index.html文件中提取javascript,并创建一个.js文件,通过webpack导入html

import Phaser from 'phaser';

function preload() {
  this.load.image('sky', 'assets/sky.png');
  this.load.image('ground', 'assets/platform.png');
  this.load.image('star', 'assets/star.png');
  this.load.image('bomb', 'assets/bomb.png');
  this.load.spritesheet('dude',
    'assets/dude.png',
    { frameWidth: 32, frameHeight: 48 });
}

function create() {
  this.add.image(400, 300, 'sky');
}

function update() {
}

const config = {
  type: Phaser.AUTO,
  width: 800,
  height: 600,
  scene: {
    preload,
    create,
    update,
  },
};

// eslint-disable-next-line no-unused-vars
const game = new Phaser.Game(config);
检查.js文件的第一行

import Phaser from 'phaser';
import Phaser from 'phaser';