Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't include GdprPopup.js #517

Open
matteorossi-thespacesm opened this issue Aug 6, 2021 · 3 comments
Open

can't include GdprPopup.js #517

matteorossi-thespacesm opened this issue Aug 6, 2021 · 3 comments
Labels

Comments

@matteorossi-thespacesm
Copy link

Question

Hello, I can't figure out how to include js file in my symfony 4.4 project. Could you tell me which part of Webpack Encore should I look into?

Thanks.

@core23 core23 added the Question label Aug 7, 2021
@core23
Copy link
Member

core23 commented Aug 7, 2021

Hi,

you need to include this little snippet inside your assets/app.js (the fiel for webpack encore):

import {GdprPopup} from '@nucleos/gdpr-bundle';

document.addEventListener('DOMContentLoaded', () => {
  new GdprPopup('.gdprpopup-container');
});

@matteorossi-thespacesm
Copy link
Author

matteorossi-thespacesm commented Aug 9, 2021

I'm afraid it's not so simple. When I launch yarn encore I get the following error:
This dependency was not found:

  • @nucleos/gdpr-bundle in ./assets/js/frontend-app.js

OK, I was able to include your script successfully by slightly editing your code:

import {GdprPopup} from '../../vendor/nucleos/gdpr-bundle/assets/widget.js';

@core23
Copy link
Member

core23 commented Aug 10, 2021

Thanks. I'm using a local tweak inside my package.json, so I can use the import mention above:

    "dependencies": {
        "@nucleos/gdpr-bundle": "file:vendor/nucleos/gdpr-bundle"
    },

I'm thinking about migrating the asset part to symfony-ux, so you have not additional step. But it requires some more time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants