-
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
Issues Related to Processing SASS Files #47
Comments
These should be resolved in |
Thanks @jclausen. I have a few observations/notes: 1. Relative paths in .scss URLs appears to be fixed! Wohoo! 2. Copying images from submodules to the same module works!
3. Images in tracked sub modules are being copied to the /includes/images folder in the app root and the submodule simultaneously when referenced in .scss files, which is odd.
4. 5. Referencing an image in the root of the project from a tracked submodule will cause the resulting css link to point to the wrong place.
Becomes this:
Which breaks the link. |
OK. I will take a look at that sourcemap issue today. I'm not sure about #5. It kind of breaks the idea of module encapsulation for a module to reference an asset from the root. Either way, So, I guess I'm confused by these two statements, which seem to conflict:
|
I know what you mean @jclausen . However, sometimes tracked submodules will need to reference global assets, like a logo, color scheme, fonts, theme, etc. Imagine a PetStore app scenario where you have Dog and Cat tracked submodules. The Dog and Cat modules would have their encapsulated functionality but may also depend on global assets like the name of the pet store, a logo, color scheme, etc. In fact, even the Ortus HMVC API convention breaks encapsulation to some degree. Tracked submodules are created in the API (e.g. /api/v1) to contain the handlers, but all of the models are placed in the root of the app, thus making them global. On a personal level, I have always looked at tracked submodules in a That being said, I believe both issues (3) and (5) are separate problems. I will try to clarify my position. Issue 3 says that images are being duplicated and copied to more than one location. Issue 5 says that if a submodule references a global asset, the URL to the global asset is not preserved. Hopefully this helps! Let me know if you need any assistance troubleshooting or if you want me to put together a test repo. |
@jclausen one other thing I noticed related to items 3 & 4 above when using production mode When running Example: |
Hi @jclausen, thanks for taking the time to assist. I have summarized a list of issues I discovered when working with .scss or .sass files in Elixir V4. We already covered item 1 yesterday on Slack. The rest of the numbered items below may also be related.
1. Relative paths are translated incorrectly when converting SASS to CSS.
Will become
The relative path should be preserved in the final output.
2. Nested/tracked submodule images are not copied to the right folder when using
mix.modules()
If you create a tracked module that has its own .scss files which reference images, the images are copied to the project's root /includes/images/ folder instead of the tracked module's /modules_app/modulename/includes/images/ folder. Here's an example:
In the above example, the
login
module has its own .scss file and image which should be copied to the /includes/ folder within the submodule. However, today, if you runmix.modules()
on the submodule, the image will be copied to the project root and the resulting CSS will point to the wrong place. The resulting css file should preserve the relative path like this:Side-note (nice-to-have): I know the convention for ColdBox is to output images in the /includes/images/ folder. However, I see a lot of developers using a folder called /img/ for images which is a nice abbreviation. It would be nice if we could configure Elixir to customize the resulting image output folder just in case we want to use a different naming scheme.
3. Source maps have the wrong path applied to them.
When processing .scss files, the resulting source map address contain the wrong path, which makes it hard for browsers to find them. Here's an example of a source
sourceMappingUrl
that was generated for a .scss file:/*# sourceMappingURL=includes\css\app.css.map*/
It should be:
/*# sourceMappingURL=app.css.map*/
Typically source maps reside in the same folder as the minified file so there's no need for an absolute path.
4. Using
mix.copy()
withinelixir-module.js
needs absolute paths from root.If you want to copy assets from a tracked module from the resources to the includes folder within that module, you must specify the absolute path from the root of the app, otherwise, Elixir won't copy the resources to the right place.
Example:
Currently, the above code will copy both the images from
/resources/assets/images
and/modules_app/modulename/resources/assets/images
to the root/includes/images
folder. The expected behavior would be to copy the/modules_app/modulename/resources/assets/images
to/modules_app/modulename/includes/
folder.The workaround for this issue is to feed the absolute path to
mix.copy()
like this:The text was updated successfully, but these errors were encountered: