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

Generation spritesmith file in a multi-page project. #36

Closed
OrionPro opened this issue May 22, 2017 · 3 comments
Closed

Generation spritesmith file in a multi-page project. #36

OrionPro opened this issue May 22, 2017 · 3 comments

Comments

@OrionPro
Copy link

OrionPro commented May 22, 2017

Generation spritesmith file in a multi-page project. For index it is formed normally, for another writes error Module not found: Error: Can not resolve './sprite.png' in ' \ webpack_template \ source \ pages \ blog'.
The file with the picture sprite.png is formed in the folder with the main entry, where the index files are, otherwise it does not work either.
How to solve this problem?
Here's my template. https://github.com/OrionPro/webpack_template
ps Sorry for my English

@OrionPro
Copy link
Author

I solved this problem by adding another new SpritesmithPlugin to create sprite.png on the new page. I think it's a crutch (not a good solution) ... but working).

@mixtur
Copy link
Owner

mixtur commented May 23, 2017

Probably that is because by saying cssImageRef: "sprite.png" you are trying to access sprite.png by relative http path.
It is not correct in general. It has to be either absolute http path, or "absolute" webpack path.
First option in your case should be something like cssImageRef: "/source/img/sprite.png".
I prefer second though. To make it work you have to change cssImageRef: "sprite.png" to cssImageRef: "~sprite.png" and configure webpack resolver with resolve.modules or resolve.alias.
https://webpack.js.org/configuration/resolve/

@OrionPro
Copy link
Author

Many thanks. Configured via resolve.alias. Now it works, as it should be all.

@mixtur mixtur closed this as completed May 23, 2017
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