错误尝试使用WebPack Encore使用Tinymce插件
我正在尝试在Textarea元素上使用Tinymce插件:
<textarea id="reportDescription" name="reportDescription" class="form-control" rows="4"></textarea>
IM与Symfony和WebPack Encore一起工作。 安装了软件包
yarn add tinymce
因此,我使用:在我编码的WebPack.config.js中
.copyFiles({
from: 'node_modules/tinymce/skins',
to: 'skins/[path]/[name].[ext]'
})
:在我尝试初始化插件的.js中:
require('tinymce');
$(document).ready(function () {
if($("#reportDescription").length > 0){
tinymce.init({
selector: "textarea#reportDescription"
});
}
});
当我将页面加载到浏览器上时,我会收到此错误:
tinymce.js:4680
GET http://url/build/models/dom/model.js net::ERR_ABORTED 404 (Not Found)
tinymce.js:18181
Failed to load model: dom from url models/dom/model.js
tinymce.js:4680
GET http://url/build/icons/default/icons.js net::ERR_ABORTED 404 (Not Found)
tinymce.js:18181
Failed to load icons: default from url http://url/build/icons/default/icons.js
tinymce.js:4680
GET http://url/build/themes/silver/theme.js net::ERR_ABORTED 404 (Not Found)
tinymce.js:18181
Failed to load theme: silver from url themes/silver/theme.js
我不明白很好,但是如何在WebPack上使用模块。如何导入它们,何时使用或导入以及它们之间的差异。所以也许我错过了一些重要的东西。
I'm trying to use the Tinymce plugin on a textarea element:
<textarea id="reportDescription" name="reportDescription" class="form-control" rows="4"></textarea>
Im working with Symfony and Webpack Encore. So I installed the package using:
yarn add tinymce
In webpack.config.js I coded:
.copyFiles({
from: 'node_modules/tinymce/skins',
to: 'skins/[path]/[name].[ext]'
})
And in the .js where I'm trying to initialize the plugin:
require('tinymce');
$(document).ready(function () {
if($("#reportDescription").length > 0){
tinymce.init({
selector: "textarea#reportDescription"
});
}
});
When I load my page on my browser, I get this error:
tinymce.js:4680
GET http://url/build/models/dom/model.js net::ERR_ABORTED 404 (Not Found)
tinymce.js:18181
Failed to load model: dom from url models/dom/model.js
tinymce.js:4680
GET http://url/build/icons/default/icons.js net::ERR_ABORTED 404 (Not Found)
tinymce.js:18181
Failed to load icons: default from url http://url/build/icons/default/icons.js
tinymce.js:4680
GET http://url/build/themes/silver/theme.js net::ERR_ABORTED 404 (Not Found)
tinymce.js:18181
Failed to load theme: silver from url themes/silver/theme.js
I don't understand very well yet how to work with modules on webpack. How to import them, when to use require or import and the difference between them. So maybe I'm missing something important.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我拥有的设置如下
安装复制WebPack插件 - YARN添加copy-webpack-plugin -dev
in webpack.config.js
i中使用刺激器,因此在刺激控制器(tiny_controller.js)中,我有下面的代码,以便所有带有Tinymce类的Textareas都将匹配
这可能是这样的。
the set up I have is as follows
install copy webpack plugin -- yarn add copy-webpack-plugin --dev
In webpack.config.js
I use stimulusjs so in the stimulus controller (tiny_controller.js) I have the code below so that all textareas with tinymce class will be matched
Finally in the HTML Form it could be something like this
尽管@patrick kenekayoro发布了一个非常不错的答案,但在您的情况下,问题是路径。您可以注意到,它在寻找
/build/models /...,因此要解决此此简单/粘贴以下代码到您的WebPack配置:
即使在最新的中,这对我也很好符号项目。
Whilst @Patrick Kenekayoro posted a really nice answer, in your scenario the issue is the path. As you can notice, it looks for
/build/models/...
, so to resolve this simply copy/paste the below code to your webpack config:This worked for me really well even in the latest Symfony projects.