【发布时间】:2018-11-22 17:48:43
【问题描述】:
一个比较新鲜的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();
【问题讨论】: