私はsymfony 4.2を使用しています。また、webpack と yarn を使用してアセットを管理しています。
以下を使用してパッケージを追加しました。
yarn add pnotify
でファイルを見ることができますnode_modules
。css ファイルと js ファイルの両方が必要です。
require('pnotify/dist/PNotifyBrightTheme.css');
require('pnotify');
このコマンドを実行すると、次のエラーが表示されます。
yarn run encore dev
app.js で pnotify を解決できません
をこれに変更するrequire
と、正常にビルドされます。
require('pnotify/dist/umd/PNotify');
このように小枝でテストしようとすると、以下のエラーが発生します。
<script type="text/javascript">
$(document).ready(function() {
(new PNotify({
title: 'Regular Notice,
text: 'Check me out! I\'m a notice.',
type: 'info',
styling: 'bootstrap3'
}));
});
</script>
> vendor.js:7803 Uncaught ReferenceError: PNotify is not defined
at HTMLDocument.<anonymous> (create:513)
at mightThrow (vendor.js:7510)
at process (vendor.js:7578)