reactjs - 无法在 Vite list : resources/js/app. jsx 中找到文件。 (npm 运行构建)

标签 reactjs laravel npm build vite

我根据本指南创建了 Laravel 应用程序:

https://bootcamp.laravel.com/

  • PHP 8.1.2
  • Laravel 9.33.0
  • react

当使用 VITE 作为开发人员(npm run dev)时,一切正常

但是当使用 VITE(npm run build)构建 JS 和 CSS 时,我收到以下错误:

无法在 Vite list 中找到文件:resources/js/app.jsx

enter image description here

php artisan 服务处于事件状态,php artisan 优化:清除已完成,npm 更新到最新版本等,但仍然是同样的问题。

如果能获得更多解决此问题的提示,那就太好了。

谢谢你,简

最佳答案

我也有同样的问题。

当我在 vite.config.js 文件中添加 'resources/js/app.jsx' 并运行 npm run 时再次构建

问题已解决。

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import react from '@vitejs/plugin-react';

export default defineConfig({
    plugins: [
        laravel({
            input: [
                'resources/css/app.css',
                'resources/js/app.js',
                'resources/js/app.jsx' --Add this
            ],
            refresh: true,
        }),
        react(),
    ],
...

希望这有帮助。

关于reactjs - 无法在 Vite list : resources/js/app. jsx 中找到文件。 (npm 运行构建),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73915206/

相关文章:

javascript - 传递额外的参数来绑定(bind)?

reactjs - 如何使用 mouseEvent 和 event.target 键入事件(使用 typescript react 项目)?

node.js - 使用Ubuntu在远程服务器上部署nodejs应用程序

php - Laravel 更新数据库有 Eloquent 问题?

laravel - 在 laravel 5 中使用包的配置文件

javascript - 问题导入 polymer 元素

javascript - 如何在reactjs中使用javascript更改样式

php - 我应该在 Laravel 中哪里放置复杂查询?

npm - 未找到 Babel 命令

reactjs - 范围错误 : Invalid typed array length: -4095 when running my react web app