symfony 我的资产不链接在我的树枝文件在生产只

p4tfgftt  于 11个月前  发布在  其他
关注(0)|答案(1)|浏览(125)

我目前正在将我的应用从Webpack迁移到Vite
我的应用程序正在使用React和Symfony。
所以我遵循了vite-bundlevite-symfony-plugin的说明。在dev server/local中,一切都运行得很好,但是当我推到我的评论应用程序时,我遇到了问题。
我的树枝渲染没有任何<script><link>从我的vite_entry_..._tag
我的资产被上传到CDN中。
你有什么想法我可以解决这个问题吗?谢谢。
以下是我的vite.config.js

export default defineConfig(({ mode }) => {
  const env = loadEnv(mode, process.cwd());

  return {
    resolve: {
      alias: {
        // ...
      },
    },
    plugins: [
      react(),
      symfonyPlugin({
        /* defaultValues */
        servePublic: true,
        refresh: true,
        /** If you set server.host: '0.0.0.0' in your vite.config.js
         * you have to set 'localhost' */
        viteDevServerHostname: null,
      }),
    ],
    base: `${env.VITE_PATH_ASSET || ''}/build`,
    build: {
      outDir: './public/build',
      manifest: true,
      rollupOptions: {
        input: {
          // ...
        },
      },
    },
    server: {
      origin: 'http://localhost:5173',
    },
  };
});

字符串

piwo6bdm

piwo6bdm1#

如果tig函数返回为空,这意味着入口点有问题。您可以尝试使用

# config/packages/pentatrion_vite.yaml
pentatrion_vite:
  throw_on_missing_entry: true

字符串
看看你的public/build/entrypoints.json,也许你可以找到信息?

// vite.config.js
export default defineConfig(({mode }) => {
  return {
    plugins: [
      symfonyPlugin(),
    ],
  
    base: mode === 'development' ? '/build/' : 'http://cdn.domain.com/build/',
  
    build: {
      outDir: './public/build', 
      manifest: true,
      rollupOptions: {
        input: {
          "app": "./assets/app.js",
        }
      },
    },
  }
});


否则,在https://github.com/lhapaipai/vite-bundle中打开一个讨论,一步一步地重现你的错误:-)

相关问题