I took a quick look at the cssSweet docs. I didn’t see anything about it being able to handle .scss files.
Do you have PhpStorm? It can be set up to process SCSS files and export them to CSS files automatically when you save an SCSS file. It also has editing help, error checking, and highlighting for editing SCSS files.
I do have SCSS preprocessing set up locally with Gulp and I even had a system set up where the .css file would FTP up to the server on save.
However I found this wasn’t ideal for my work process and was a bit tedious especially as I would have to wait for the file to FTP and then manually clear the MODX cache each time I wanted to view changes.
I was hoping I could use something like cssSweet for simple sites where I could just login and makes changes on the fly from any computer.
I thought cssSweet might be able to handle imports as there is a commented out example import line example .scss chunk.
I also found this line in the saveCustomCss chunk:
// Optionally set base_path for scss imports
$scss_import_paths = $modx->getOption('scss_import_paths', $properties, '');
$scss_import_paths = (empty($scss_import_paths)) ? array() : $csssweet->explodeAndClean($scss_import_paths);
You’re right. I looked deeper in the code and the extra not only appears to handle SCSS files, but it looks like it has a built-in SCSS compiler.
I found your code example above and I’m guessing that rather than using @import you need to put a comma-separated list of paths to the SCSS file(s) you want to import in the saveCustomCss plugin’s scss_import_paths property. My guess is that the extension should be included in the filename, and you may need a full absolute or relative path, depending on where the files are.
An alternative is to put the SCSS code in one or more chunks, leave the scss_import_paths empty and put a comma-separated list of the chunk names in the plugin’s scss_chunks property. This feature looks like it might not have been fully tested.
FWIW, I don’t think this code would work reliably in MODX 3, though it might not take too much work to fix it.
No, I don’t actually have cssSweet installed. I just looked at the code on GitHub.
You could edit the properties in PhpMyAdmin in the modx_site_plugins table. The properties field contains a JSON string. Somewhere in it there’s probably a scss_import_paths:"" bit. You could just fill in your info between the double quotes. Same for the scss_chunks property.
The failure to save is usually due to an issue with some mod_security rule on the server not liking a part of the content.
I had setup a development site last year that used a modified version of cssSweet (with the help of @sepiariver and @sottwell) that use MODX resources as the source. Very convenient to modify the files and to leverage TVs and system settings. It never got to production. I might be able locate it if you are interested.
This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.