我在 Symfony 4.2 项目中工作,并尝试使用 Bootstrap 主题(所以我需要编译 Sass 代码)。我按照官方文档中给出的流程进行操作,该文档指示使用 webpack-encore。但我在根据文档使用它时遇到错误。
这是指示该过程的页面: https://symfony.com/doc/current/frontend/encore/simple-example.html
所以我安装了 Encore,然后启动yarn run encore
. 这是终端中的内容:
yarn run v1.16.0
warning package.json: No license field
error Command "encore" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Run Code Online (Sandbox Code Playgroud)
所以我访问了错误中指示的网站,其中显示:
如果我查看根目录中的 package.json,它确实只显示:
"devDependencies": {
"bootstrap": "^4.3.1",
"jquery": "^3.4.1",
"node-sass": "^4.12.0",
"popper": "^1.0.1",
"sass-loader": "^7.0.1"
}
}
Run Code Online (Sandbox Code Playgroud)
没有任何 encore 命令的脚本:-(
不过其余的似乎都不错。这是composer.json的摘录:
...
"require": {
...
"symfony/webpack-encore-bundle": "^1.5",
...
},
...
Run Code Online (Sandbox Code Playgroud)
我有一个 webpack.config.js 。
我运行了composer require encore
并且 …
我正在使用 Webpack Encore 进行 Symfony 4 项目。使用yarn encore dev
,我收到此错误:
ERROR Failed to compile with 2 errors 11:45:38
These dependencies were not found:
* core-js/modules/es.regexp.exec in ./assets/js/poteauxskip.js
* core-js/modules/es.string.match in ./assets/js/poteauxskip.js
To install them, you can run: npm install --save core-js/modules/es.regexp.exec core-js/modules/es.string.match
Run Code Online (Sandbox Code Playgroud)
并且 Regexp 表达式不起作用。我试着按照他们说的安装,但这是各种问题的开始。但主要是,它没有解决主要问题,即:为什么这不起作用?我认为没有理由在我的 javascript 文件中导入任何内容以使用 Regexp,我在整个解决方案研究中都没有发现这一点。
poteauxskip.js 文件:
const $ = require('jquery');
$(".tableau").addClass("d-none");
$(".serie").change(function(){
updateTableaux();
});
function updateTableaux() {
var serie1 = $("select#serie1").val() == '?' ? '[0-9A-F]' : $("select#serie1").val();
var serie2 = $("select#serie2").val() == '?' ? '[0-9A-F]' …
Run Code Online (Sandbox Code Playgroud)