Closed YUCLing closed 1 year ago
This is the output of inline-script-query
test after adding pretty: true
● inline style & script › inline script using URL query `?inline`
expect(received).toEqual(expected) // deep equality
- Expected - 1
+ Received + 14
- <!DOCTYPE html><html><head><title>Test</title><script src="assets/js/main.992ba657.js" defer="defer"></script><script>(()=>{"use strict";console.log(">> inline script from inline-main.js",7)})();</script></head><body><h1>Home</h1></body></html>
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <title>Test</title>
+ <script src="assets/js/main.992ba657.js" defer="defer"></script>
+ <script>
+ F: /pug-plugin-master/test / cases / inline - script - query / src / assets / scripts / inline - main.js
+ </script>
+ </head>
+ <body>
at test (index.test.js:341:3)
at Object.describe (index.test.js:340:1)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 114 passed, 115 total
Snapshots: 0 total
Time: 22.352 s
@YUCLing
thank you for the bug report! I wil fix it.
@YUCLing
the issue is fixed in v4.9.1
Thank You!
Confirmed. Works perfectly 😄
As I mentioned in https://github.com/webdiscus/pug-plugin/issues/56#issuecomment-1384360526, the inline JS was not working.
By looking through the process that HTML code being processed, I found that
Pretty.format
turned<script>I:/ulr-loading/test/config.ts</script>
into<script>\n I: /ulr-loading/test / config.ts\n </script>
.https://github.com/webdiscus/pug-plugin/blob/29aa357fbf5f0877da5f36e34c41659c60241211/src/AssetScript.js#L146
This is where the JS code being inserted into HTML, but after prettify, the text used to replace was no longer existed.