我试图将Symfony应用程序部署到生产中。
我已经运行了命令:
yarn encore prod我仍然看到以下例外情况:
在模板的呈现过程中抛出了一个异常(“无法找到Webpack的入口点文件:文件"/home/mobil/public_html/public/build/entrypoints.json”不存在“)。
我如何解决我的问题?
发布于 2022-10-05 15:22:04
如果我不是一个共享主机,我认为我是因为setPublicPath配置。我以前遇到过一个小问题,资产在本地运行,但在服务器上不起作用,解决方案是为本地配置两个webpack配置,第二个配置为prod配置。
Encore
// directory where compiled assets will be stored
.setOutputPath('public/build/')
.setPublicPath('/build') // local config
.setManifestKeyPrefix('build/')
// ........
})
;
const localConfig = Encore.getWebpackConfig();
localConfig.name = 'localConfig';
// reset Encore to build the second config
Encore.reset();
Encore
// directory where compiled assets will be stored
.setOutputPath('public/build/')
.setPublicPath('/public/build') // for prod on shared hosting
.setManifestKeyPrefix('build/')
// .....
// build the second configuration
const prodConfig = Encore.getWebpackConfig();
// Set a unique name for the config (needed later!)
prodConfig.name = 'prodConfig';
// export the final configuration as an array of multiple configurations
module.exports = [localConfig, prodConfig];每个配置的命令:
./node_modules/.bin/encore dev --config-name localConfig
./node_modules/.bin/encore prod --config-name prodConfighttps://stackoverflow.com/questions/73960815
复制相似问题