Skip to content

Please ignore imports that start with things like '!!raw!' #170

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

Closed
jjinux opened this issue Mar 28, 2018 · 6 comments
Closed

Please ignore imports that start with things like '!!raw!' #170

jjinux opened this issue Mar 28, 2018 · 6 comments

Comments

@jjinux
Copy link
Contributor

jjinux commented Mar 28, 2018

I have some code that pulls in an import like:

import icomoonCss from '!!raw!base-components/universal/icomoon/icomoon.global.less';

It's working with the .less source code dynamically. The current ways that you can configure the project to skip files (i.e. exclude) don't work because they happen after the file has already been resolved. It doesn't work with something that starts with '!!raw!'. I'm not sure how common this is, but it'd be nice to just ignore imports like that.

@jjinux
Copy link
Contributor Author

jjinux commented Mar 28, 2018

In src/index.js, it says:

if (stats.opts.exclude && getTargetResourcePath(path, stats).match(new RegExp(stats.opts.exclude))) {

getTargetResourcePath assumes you can resolve the path. That doesn't work for '!!raw!'.

I suspect it also doesn't work very well if you're making use multiple roots by having multiple things in Webpack's resolve.modules list, but that's a separate issue ;)

@gajus
Copy link
Owner

gajus commented Apr 7, 2018

I don't fully comprehend the use case, but I can see there being a use case for wanting to exclude certain styles from being included.

Refer to the exclude configuration.

@gajus gajus closed this as completed Apr 7, 2018
@jjinux
Copy link
Contributor Author

jjinux commented Apr 16, 2018

This problem happened to me again today. I was importing a less file via import themeVariables from '!less-vars!./variables.global.less';. That way, I could use the less styles via JavaScript. I think it just should ignore imports that start with '!'.

@jjinux
Copy link
Contributor Author

jjinux commented Apr 16, 2018

And, btw, exclude doesn't work. See my description at the top.

@jjinux
Copy link
Contributor Author

jjinux commented Apr 16, 2018

I think it should just ignore all imports that start with ! because it's a sign that a Webpack loader is going to do some additional processing.

@jjinux
Copy link
Contributor Author

jjinux commented Apr 19, 2018

Please see: #178

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

No branches or pull requests

2 participants