php - Symfony Webpack:无法从 Webpack 中找到入口点文件
问题描述
一个比较新鲜的 Symfony 4.1.7 项目安装 Webpack Encore 后抛出错误
在渲染模板期间抛出异常(“无法从 Webpack 中找到入口点文件:文件“.../public/build/entrypoints.json”不存在。”)
{{ encore_entry_link_tags('app') }}
启动时模板包含的位置
http://127.0.0.1:8000/
我错过了什么?
$ yarn encore dev
Running webpack ...
DONE Compiled successfully in 1974ms
I 3 files written to public\build
Done in 3.33s.
.../public/build
包含
app.css
app.js
manifest.json
本地 Symfony 版本:
symfony/webpack-encore-bundle v1.0.0
symfony/webpack-encore-pack v1.0.3
webpack.config.js:
var Encore = require('@symfony/webpack-encore');
Encore
// the project directory where compiled assets will be stored
.setOutputPath('public/build/')
// the public path used by the web server to access the previous directory
.setPublicPath('/build')
.cleanupOutputBeforeBuild()
.enableSourceMaps(!Encore.isProduction())
// uncomment to create hashed filenames (e.g. app.abc123.css)
// .enableVersioning(Encore.isProduction())
// uncomment to define the assets of the project
.addEntry('app', './assets/js/app.js')
// .addEntry('js/app', './assets/js/app.js')
// .addStyleEntry('css/app')
// .addStyleEntry('css/app', './assets/css/app.scss')
// uncomment if you use Sass/SCSS files
// .enableSassLoader()
// uncomment for legacy applications that require $/jQuery as a global variable
.autoProvidejQuery()
;
module.exports = Encore.getWebpackConfig();
解决方案
在 package.json 中为 @symfony/webpack-encore 更新你的版本约束到 ^0.21.0
...
"devDependencies": {
"@symfony/webpack-encore": "^0.21.0",
...
将 .enableSingleRuntimeChunk() 添加到您的 webpack.config.js
...
.addEntry('app', './assets/js/app.js')
// .addEntry('js/app', './assets/js/app.js')
// .addStyleEntry('css/app')
// .addStyleEntry('css/app', './assets/css/app.scss')
.enableSingleRuntimeChunk()
...
然后运行 yarn upgrade 或 yarn install
PS:如果你安装了 symfony/webpack-encore-bundle,你可以删除 symfony/webpack-encore-pack
composer remove symfony/webpack-encore-pack
推荐阅读
- atata - 使用带小数点的 Set() 时的 FireFox NumberInput 和 TextInput 行为
- vba - CATIA V5 VBA 中是否有返回当前打开文件名称的命令或字符串?
- r - R - 是否有一种简洁的方法可以为长数据帧中的每个组获取折刀平均值
- airflow - 如何在另一个任务气流中使用查询结果(bigquery 运算符)
- java - Mongo 数据库套接字异常
- c# - 当我使用 Visual Studio 发布向导将 Blazor WASM 站点发布到第三方主机时,我的 web.config 转换没有任何效果
- tensorflow - Tensorflow Extended (TFX):有没有一种简单的方法可以从 Transorm 组件中调试函数?
- javascript - C#:从 Web 服务返回的字节 [] 在新选项卡中显示 PDF
- c - 如何在 c 中减少相同的 if-else
- reactjs - 在 React 表单中访问子组件的值