Php 致命错误:未捕获的细枝\error\SyntaxError:Unknown";“资产”;功能
我有一个wordpress主题,使用Twig2.0构建,使用网页encore bundle作为资产。问题是“资产”在html中不起作用 如何使用img src标记中的资产加载图像 我正在使用PHP7.3.0 代码如下: HTML:Php 致命错误:未捕获的细枝\error\SyntaxError:Unknown";“资产”;功能,php,symfony,webpack,twig,Php,Symfony,Webpack,Twig,我有一个wordpress主题,使用Twig2.0构建,使用网页encore bundle作为资产。问题是“资产”在html中不起作用 如何使用img src标记中的资产加载图像 我正在使用PHP7.3.0 代码如下: HTML: <div> <img src="{{ asset('build/search.png') }}"/> </div> WEBPACK.CONFIG.JS var Encore = require('@sym
<div>
<img src="{{ asset('build/search.png') }}"/>
</div>
WEBPACK.CONFIG.JS
var Encore = require('@symfony/webpack-encore');
if (!Encore.isRuntimeEnvironmentConfigured()) {
Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev');
}
Encore
.setOutputPath('public/build/')
.setPublicPath('/build')
.setManifestKeyPrefix('build/')
.copyFiles({
from: './assets/images'})
.addEntry('app', './assets/js/script.js')
.splitEntryChunks()
.enableSingleRuntimeChunk()
.cleanupOutputBeforeBuild()
.enableBuildNotifications()
.enableSourceMaps(!Encore.isProduction())
// enables hashed filenames (e.g. app.abc123.css)
.enableVersioning(Encore.isProduction())
// enables @babel/preset-env polyfills
.configureBabelPresetEnv((config) => {
config.useBuiltIns = 'usage';
config.corejs = 3;
})
;
module.exports = Encore.getWebpackConfig();
composer.lock/composer.json的外观如何?你有网页依赖性吗?哇,Wordpress里的小树枝!我第一次看到这个!资产函数来自
Symfony\Bridge\Twig\Extension
命名空间(至少在我使用的版本中),您能否验证类Symfony\Bridge\Twig\Extension\AssetExtension
是否以某种方式加载。另外,能否显示composer文件或composer show的结果?composer.lock/composer.json的外观如何?你有网页依赖性吗?哇,Wordpress里的小树枝!我第一次看到这个!资产函数来自Symfony\Bridge\Twig\Extension
命名空间(至少在我使用的版本中),您能否验证类Symfony\Bridge\Twig\Extension\AssetExtension
是否以某种方式加载。此外,您是否可以显示composer文件或composer show的结果?
var Encore = require('@symfony/webpack-encore');
if (!Encore.isRuntimeEnvironmentConfigured()) {
Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev');
}
Encore
.setOutputPath('public/build/')
.setPublicPath('/build')
.setManifestKeyPrefix('build/')
.copyFiles({
from: './assets/images'})
.addEntry('app', './assets/js/script.js')
.splitEntryChunks()
.enableSingleRuntimeChunk()
.cleanupOutputBeforeBuild()
.enableBuildNotifications()
.enableSourceMaps(!Encore.isProduction())
// enables hashed filenames (e.g. app.abc123.css)
.enableVersioning(Encore.isProduction())
// enables @babel/preset-env polyfills
.configureBabelPresetEnv((config) => {
config.useBuiltIns = 'usage';
config.corejs = 3;
})
;
module.exports = Encore.getWebpackConfig();