-
Notifications
You must be signed in to change notification settings - Fork 9
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
Revert breaking change from V3 #42
Conversation
Prevent css-loader from trying to modify URLs. This was a breaking change from V3 that is not needed.
Note: there is still a breaking issue in V4 that I have yet to figure out how to solve. This PR addresses the error that is generated in Webpack during a build. The remaining issue is that URLs are renamed relative to the original path in SCSS files, when they should be untouched as they were in Elixir V3. For example, lets say you have the following SCSS:
Elixir V4 will rename the URL in the resulting CSS file thus breaking the link.
I do not know how to fix this issue and probably need some outside help to solve it. |
This SO post may be of some help: |
I can't merge this, as is, as it will break other implementations which are using images from a source directory and copying them over to final If I'm understanding correctly, you don't want those files referenced to be sourced in during the pack and consolidated to an This config addition, from the SO post linked above though might allow it to skip out if it can't locate the file.
I will test this with some root-relative links in existing apps to see if I can get it to ignore the bad paths. My main concern is that it won't re-attempt to find other assets. |
I've created Issue #44 to address this for future releases. My recommendation, for now, would be to update the links to the files to be resolvable from the root of the project, when compiled. As long as absolute URLs are resolvable, they are not compiled in to the
|
@jclausen Thank you for the feedback and for creating issue 44.
Unfortunately, when building Coldbox modules, making links to assets resolvable from the root is not always easy. When developing, the module might load from a /test-harness/ folder and, in production, it would load via the modules/myModuleName folder. There's also no way to know how deep down in the dependency hierarchy a module's assets might exist from the app root (e.g. /modules/myModule1/modules/myModule2) One way I have solved this problem in the past is by using web server folder aliases (aka rewrite/redirect rules) like this one in a module's test-harness folder:
I make SCSS URLs based on the root, but webpack has no way of knowing that web server redirects/aliases handle the actual mapping. Does that make sense? |
It makes total sense. I deal with this issue with both the I can just use the standard When the module is deployed, though, the links work perfectly. |
I'm glad to know I'm not the only one! Haha. In
The above link would cause an error when running Webpack, similar to what I experienced, wouldn't it? You would have to manually override some of the Webpack configuration so that URL's remain untouched in your CSS/SCSS |
The way I would do is is to use a relative link, since the
You can also set it to inline the
For small images like logos and other things, this is super handy. |
Thank you! I will experiment with making the links relative. |
@jclausen, sorry for the continued posts on this issue, but I have a related question regarding images. I'm coming from the Gulp world, so I am used to processing scss and images in separate tasks. Elixir + Webpack appears to process scss + images together via sass-loader, as far as I can tell. When sass-loader comes across a reference to an image, it copies it from the /resources/assets/img/ folder to /includes/images/ For example:
I have two questions related to this process:
I know I can write extensions for Elixir, but if sass-loader is taking over control and copying over every image it discovers, wouldn't this negate any image processing I set up in the future? |
I discovered another thing when switching to relative paths in my scss files. |
Prevent css-loader from trying to modify URLs. This was a breaking change from V3 that is not needed.