小编Yur*_*rsh的帖子

使用 webpack-dev-middleware 时如何在 Phaser 应用程序中加载图像?

我有 Webpack/Phaser/Express 项目。当我加载应用程序时,Chrome 控制台中无法加载图像并出现以下错误:

GET http://localhost:8080/assets/ui/blue_button03.png 500 (Internal Server Error)

GET http://localhost:8080/assets/ui/blue_button02.png 500 (Internal Server Error)
Run Code Online (Sandbox Code Playgroud)

将这些图像加载到移相器中:

this.load.image('blueButton1', 'assets/ui/blue_button02.png');
this.load.image('blueButton2', 'assets/ui/blue_button03.png');
Run Code Online (Sandbox Code Playgroud)

我在尝试包含在移相器代码中的每个静态文件上都遇到了相同的错误。

网页包配置:

const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');

// Phaser webpack config
const phaserModule = path.join(__dirname, '/node_modules/phaser/')
const phaser = path.join(phaserModule, 'src/phaser.js')

const definePlugin = new webpack.DefinePlugin({
    __DEV__: JSON.stringify(JSON.parse(process.env.BUILD_DEV || 'true')),
    WEBGL_RENDERER: true, // I did this to make webpack work, but I'm not really sure it should always be true
    CANVAS_RENDERER: true …
Run Code Online (Sandbox Code Playgroud)

express phaser-framework webpack webpack-dev-middleware

5
推荐指数
1
解决办法
1304
查看次数