首页 > 解决方案 > 使用 Webpack 构建并部署到 Netlify 的 PixiJS 应用程序中的“未捕获的 TypeError:r(...) 不是函数”

问题描述

我用 PixiJS 开发了一个游戏项目,并用 Webpack 构建了它。在本地主机上它工作正常,但是当我在 Netlify 上部署它时,它显示以下错误:

VM867 index.js:2 Uncaught TypeError: r(...) is not a function
    at Object.6168 (VM867 index.js:2)
    at r (VM867 index.js:2)
    at Object.7912 (VM867 index.js:2)
    at r (VM867 index.js:2)
    at Object.5474 (VM867 index.js:2)
    at r (VM867 index.js:2)
    at Object.5173 (VM867 index.js:2)
    at r (VM867 index.js:2)
    at Object.7042 (VM867 index.js:2)
    at r (VM867 index.js:2)

我想 Webpack 配置一定有问题。这里是:


    const path = require('path')
    const HtmlPlugin = require('html-webpack-plugin')
    const CopyWebpackPlugin = require('copy-webpack-plugin')
    const ImageminPlugin = require('imagemin-webpack-plugin').default
    module.exports = {
    
      context: path.join(__dirname, 'src'),
    
      entry: ['./index.js'],
      output: {
    
        path: path.resolve(__dirname, 'dist'),
        filename: 'index.js',
      },
      module: {
        rules: [
            {
                test: /\.(css)$/,
                use: ['style-loader','css-loader']
            }
        ]
      },
      target: 'web',
    
    plugins: [
    
      new CopyWebpackPlugin({
        patterns: [
        { from: 'img/',to:'assets/'}
      ]}),
    
      new ImageminPlugin({
        test: /\.(jpe?g|png|gif|svg)$/i ,
        pngquant: {
          verbose:true,
          quality: '80-90',
        }
      })
      ,new HtmlPlugin({
        file:path.join(__dirname,'dist','index.html'),
        template:'./index.html'
      })
    ]
    }

这是整个存储库:https://github.com/EgorKorshunov/life-in-space 在 src 文件夹中 index.js 是主脚本文件。

标签: javascriptwebpacknetlifypixi.js

解决方案


推荐阅读