From ec87fdd5b60aaab7bd44feafd12641c4a4e1bde6 Mon Sep 17 00:00:00 2001 From: Azul Date: Wed, 26 Jul 2017 10:55:11 +0200 Subject: Revert "fix: make customization available to sass" This reverts commit cc95bb27e873dc6140f9a909a57f075a0ef2f387. --- config/initializers/customization.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/config/initializers/customization.rb b/config/initializers/customization.rb index 2b5301e..6d9c741 100644 --- a/config/initializers/customization.rb +++ b/config/initializers/customization.rb @@ -21,7 +21,6 @@ customization_directory = APP_CONFIG["customization_directory"] # Rails.application.config.assets.paths.unshift "#{customization_directory}/images" Rails.application.config.assets.paths.unshift "#{customization_directory}/stylesheets" -Rails.application.config.sass.load_paths.unshift "#{customization_directory}/stylesheets" # # Copy files to public # -- cgit v1.2.3 From d939562360377dad4dfd8ab1520b15f85fc0a730 Mon Sep 17 00:00:00 2001 From: Azul Date: Wed, 26 Jul 2017 11:19:41 +0200 Subject: custom: fix stylesheet customization fixes #8794 Reported the underlying issue here: https://github.com/rails/sass-rails/issues/406 Basically `@import` works like this: * look for the file relative to the current file * look for the file as an absolute path following the priorities in the * asset load_paths If the file can be imported as a relative path that will take precedence. So in order to pick up the head and tails inside customization rather than in app/assets there are three possibilities: 1) use an absolute path. This is not as easy as it seems. There is no way of indicating a path is meant to be absolute so we would have to ensure it does not resolve to a relative path. 2) have a application.scss file inside the customization folder. Since this is the main file it will be used instead of the app/assets one. In there relative paths will now also default to the customization folder rather than app/assets. Once we are in an app/assets file though it will not go back to picking up customization with relative paths 3) use //= require instead of import. rails-sass advices against this as each required file would be compiled on it's own and variables could not be shared. Going with option 1 here: ```scss // application.scss: @import "custom/head_import"; ``` ```scss // custom/head_import.scss: @import "head"; ``` As long as there is no custom/head.scss in app/assets it will import head as an absolute path and thus prefer config/custom over app/assets. This seems like the best option for now as it does not require changes to the deployments. --- app/assets/stylesheets/application.scss | 12 ++++++++---- app/assets/stylesheets/custom/head-import.scss | 1 + app/assets/stylesheets/custom/tail-import.scss | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 app/assets/stylesheets/custom/head-import.scss create mode 100644 app/assets/stylesheets/custom/tail-import.scss diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index f42044b..1fed154 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -1,7 +1,9 @@ // -// import custom scss, content to be set in deployment. +// This will in turn import config/customization/stylesheets/head +// It is a workaround for sass-rails defaulting to relative imports. +// https://0xacab.org/leap/webapp/issues/8794 // -@import "head"; +@import "custom/head-import"; // First import journal variables // @import "bootswatch/cerulean/variables"; @@ -22,6 +24,8 @@ // @import "bootswatch/cerulean/bootswatch"; // -// import custom scss, content to be set in deployment. +// This will in turn import config/customization/stylesheets/tail +// It is a workaround for sass-rails defaulting to relative imports. +// https://0xacab.org/leap/webapp/issues/8794 // -@import "tail"; +@import "custom/tail-import"; diff --git a/app/assets/stylesheets/custom/head-import.scss b/app/assets/stylesheets/custom/head-import.scss new file mode 100644 index 0000000..c097d8d --- /dev/null +++ b/app/assets/stylesheets/custom/head-import.scss @@ -0,0 +1 @@ +@import "head"; diff --git a/app/assets/stylesheets/custom/tail-import.scss b/app/assets/stylesheets/custom/tail-import.scss new file mode 100644 index 0000000..3a61253 --- /dev/null +++ b/app/assets/stylesheets/custom/tail-import.scss @@ -0,0 +1 @@ +@import "tail"; -- cgit v1.2.3