我正在尝试在我的Symfony 3.3项目中使用SensioLab Webpack Encore,但是在向webpack添加几个脚本后,我的脚本没有看到其他脚本的功能.
的package.json
{
"name": "HIDDEN",
"version": "1.0.0",
"license": "UNLICENSED",
"description": "HIDDEN",
"repository": {
"url": "HIDDEN",
"type": "git"
},
"author": "Alexey Samara <HIDDEN>",
"dependencies": {
"jquery": "3.1.1",
"expose-loader": "0.7.3",
"bootstrap": "3.3.7",
"datatables.net": "1.10.15",
"datatables.net-buttons": "1.4.0",
"datatables.net-buttons-bs": "1.4.0",
"html5shiv": "^3.7.3",
"respond.js": "^1.4.2",
"metismenu": "2.7.0",
"slimscroll": "0.9.1",
"pace-js": "1.0.2",
"gritter": "1.7.4",
"toastr": "2.1.2",
"jquery.flot": "0.8.3",
"jquery.flot.tooltip": "0.9.0",
"ecore-template-skeleton-static": "git+ssh://HIDDEN"
},
"devDependencies": {
"@symfony/webpack-encore": "^0.11.0",
"node-sass": "^4.5.3",
"sass-loader": "^6.0.6"
}
}
Run Code Online (Sandbox Code Playgroud)
webpack.config.json
var Encore = require('@symfony/webpack-encore'),
eCoreTemplatePath = './node_modules/ecore-template-skeleton-static/';
Encore
.setOutputPath('web/build/') …Run Code Online (Sandbox Code Playgroud) 对于 Symfony,我使用翻译、Twig 和Webpack encore组件。
我可以在前端 Twig 中翻译:
'my_key'|trans
Run Code Online (Sandbox Code Playgroud)
我使用命令yarn encore dev生成我的app.js,但PHP 翻译组件无法在 Javascript 中访问。
我有很多东西要用 javascript 翻译。
我正在使用 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) 我在使用 Symfony 5、encore、stimulus 等加载 Bootstrap 的 js 时遇到困难...
jquery、popper、corejs 等都已安装,并且至少 jquery 正在工作......
app.scss 和 app.js 似乎可以使用 sass、postcss 和 babel(包括 Bootstrap 的 CSS)很好地编译。只是 Bootstrap 的 JS 不存在,所以没有下拉菜单等。
资产/app.js
// any CSS you import will output into a single css file (app.css in this case)
import './styles/app.scss';
// start the Stimulus application
import './bootstrap';
Run Code Online (Sandbox Code Playgroud)
资产/引导程序,js
import { startStimulusApp } from '@symfony/stimulus-bridge';
// Registers Stimulus controllers from controllers.json and in the controllers/ directory
export const app = startStimulusApp(require.context(
'@symfony/stimulus-bridge/lazy-controller-loader!./controllers',
true,
/\.(j|t)sx?$/
));
// …Run Code Online (Sandbox Code Playgroud)