如何在 webpack-encore 中导入 appear.js?

How to import appear.js in webpack-encore?

我用yarn add安装出现。但是 import 'appear'; 的导入不起作用。

你可以这样做:

webpack.config.js:

Encore
.addEntry('app', './assets/js/app.js')

assets/js/app.js:

// could add css here too

require('appear'); // might be necessary to add path like with fontawesome '@fortawesome/fontawesome-free/css/all.css'

树枝模板css:

{% block stylesheets %}
    {{ encore_entry_link_tags('app') }}
{% endblock %}

树枝模板 js:

{% block javascripts %}
    {{ encore_entry_script_tags('app') }}
{% endblock %}