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

[Windows] Inline CSS not working due to the difference between sourceRequest and rawRequest #56

Closed
YUCLing opened this issue Jan 12, 2023 · 4 comments
Milestone

Comments

@YUCLing
Copy link

YUCLing commented Jan 12, 2023

I'm trying to use inline CSS with the plugin, but what i got inside style is the resource url of the SCSS I required.

For example, if I use inline CSS using style=require('./styles.scss?inline'), the content of style will be style.3ef5f.css instead of the CSS code generated by webpack.

After some research, I found that the sourceRequest (index.js#L655) added to AssetSource is different from rawRequest (Resolver.js#L286) used by require.
The sourceRequest's path separator is \, which is Windows style (I'm working on Windows).
The rawRequest's path separator is /.
If I replace all / in rawRequest to \ using debugger, everything is working as expected.

@YUCLing YUCLing changed the title Inline CSS not working due to the difference between sourceRequest and rawRequest [Windows] Inline CSS not working due to the difference between sourceRequest and rawRequest Jan 12, 2023
@webdiscus
Copy link
Owner

Hello @YUCLing,

thank you for the issue report.
I will try to fix it.

@webdiscus webdiscus added this to the analyse milestone Jan 12, 2023
@webdiscus
Copy link
Owner

@YUCLing

the bug is fixed in v4.9.0, please update the package.

P.S. in v.4.9.0 is added supports for inline JS, see How to inline JS in HTML

@webdiscus webdiscus modified the milestones: analyse, done Jan 16, 2023
@YUCLing
Copy link
Author

YUCLing commented Jan 16, 2023

Confirmed it's fixed.

But your inline JS seems to be not working properly. I'm not sure what caused it, I will try to find out when possible and open an new issue if necessary.
The following output is what I got from inline JS.

script=require("../test/config.ts?inline")

Outputs

<script>
  I: /path-to-project/test / config.ts
</script>

@YUCLing YUCLing closed this as completed Jan 16, 2023
@webdiscus
Copy link
Owner

@YUCLing

I have the inline script test. It's work.
You can do your own test based on my test to reproduce the issue.

P.S. yes, create please new issue for inline script.

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

No branches or pull requests

2 participants