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

"Not allowed to load local resource" when adding a script from node modules #65

Closed
Jeneko opened this issue Mar 4, 2023 · 4 comments
Closed
Labels
bug Something isn't working
Milestone

Comments

@Jeneko
Copy link

Jeneko commented Mar 4, 2023

Good day! I'm trying to add Bootstrap to my project when using pug-plugin. As recipes said I do:

script(src=require('bootstrap/dist/js/bootstrap.bundle.js'))

Then I start webpack-dev-server. And everything goes good until I make a change in any .scss or .js file of the project and then save the file. After page autoreload I get this error in browser console:

error-image

Strangely enough, if I make a change in .pug file the error doesn't appear. And if I put bootstrap.bundle.js out of /node_modules somewhere into /src and load it from there the error also does not appear.

As a test I add Bootstrap in the standard pug-plugin example "simple-multipage". Here is the repo

@webdiscus webdiscus added this to the analyse milestone Mar 4, 2023
@webdiscus
Copy link
Owner

Hello @Jeneko,

Thanks for reporting the issue, I'll fix it.

@Jeneko
Copy link
Author

Jeneko commented Mar 4, 2023

@webdiscus, thank you very much!

@webdiscus webdiscus modified the milestones: analyse, in devolopment Mar 7, 2023
@webdiscus webdiscus added the bug Something isn't working label Mar 7, 2023
@webdiscus webdiscus modified the milestones: in devolopment, in testing Mar 8, 2023
webdiscus added a commit that referenced this issue Mar 10, 2023
- fix: correct inline JS when used split chunks
- refactor: optimize code for script processing
- test: add manually test for missing node modules after rebuild
webdiscus added a commit that referenced this issue Mar 10, 2023
- fix: correct inline JS when used split chunks
- refactor: optimize code for script processing
- test: add manually test for missing node modules after rebuild
webdiscus added a commit that referenced this issue Mar 10, 2023
- fix: correct inline JS when used split chunks
- refactor: optimize code for script processing
- test: add manually test for missing node modules after rebuild
@webdiscus webdiscus modified the milestones: in testing, release Mar 10, 2023
@webdiscus
Copy link
Owner

webdiscus commented Mar 10, 2023

@Jeneko

the issuer is fixed in v4.9.7.

Note

You can load CSS and JS from a node module using only module name without a path to a file in module.
The plugin automatically detect the default CSS and default JS defined in package.json of the module.

For example:
link(href=require("bootstrap") rel="stylesheet") => resolves the bootstrap/dist/css/bootstrap.css
script(src=require("bootstrap")) => resolves the bootstrap/dist/js/bootstrap.js

You can see the working example watch-dependencies-bootstrap.

@Jeneko
Copy link
Author

Jeneko commented Mar 10, 2023

@webdiscus
Thanks a lot for the quick fix! Everything works perfect!

@Jeneko Jeneko closed this as completed Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants