Open Samirbekaert opened 9 years ago
Hi, I had the same problems at the beginning :)
In your case, if you have CSS files linked to HTML files by "link" element, uncss should know where he find the CSS to process - removing an 'csspath' property from config should help.
Thanks for your answer. I removed csspath
from the config but I still get the same error when I run brunch build --production
:
error: UnCSS: no stylesheets found
Where is it looking exactly? In the public
(build) folder and its subdirectories? It's actually strange because when the error throws the build process stops and the /stylesheets
folder is the only folder that is missing from the build directory.
The uncss plugin is the last one in my package.json so I assumed the plugin doesnt interfere with my css building. It's a mystery to me why it actually does.
"dependencies": {
"auto-reload-brunch": ">= 1.0 < 1.8",
"clean-css-brunch": ">= 1.0 < 1.8",
"css-brunch": ">= 1.0 < 1.8",
"javascript-brunch": ">= 1.0 < 1.8",
"less-brunch": "^1.7.2",
"uglify-js-brunch": ">= 1.0 < 1.8",
"uncss-brunch": "^1.0.1"
}
OK. How it's look in my projects.
I have "three steps" directories structure:
/root
--development/
--build/
--release/
In 'development' dir I write the code (CoffeeScript, SASS, etc.). Brunch is 'watching' (brunch w
) on 'development' and moving processed code to the 'build' directory.
When I run brunch build -P
, code is processed by plugins, optimisers... - now I have code in 'release' dir.
In above, 'htmlroot' is set on an 'build' directory.
ah so you have 2 separate distribution directories: /build
and /release
. This indeed seems logical for allowing the uncss plugin to work from finished/compiled stylesheets.
Can I see your brunch config file so I can mimic that setup? In any case, this already is an unconventional setup so we should definitely consider adding it to the readme later.
@jakubburkiewicz would be a great help. Really want to get this working. thx
@Samirbekaert I figured it out!
I suggest you add the sample code below to your brunch config file.
overrides:
release:
paths:
public: 'release'
sourceMaps: false
plugins:
on: ['uncss-brunch']
uncss:
options:
ignore: [/\.\bactive\b/]
ignoreSheets: [/fonts.googleapis/]
files: ['public/index.html']
You can invoke the release build with command:
brunch build -e release
brunch build -P
brunch build -e release
ignore: sample regex to ignore '.active' class ignoreSheets: sample regex to ignore Google fonts
You may need to ignore all other CSS files linked to 'public/index.html' by "link" element other than '/stylesheets/style.css'. Alternatively, you can add "stylesheets" key to uncss options, to avoid having to add "ignoreSheets".
stylesheets: ['/stylesheets/style.css']
Seems as if uncss-brunch is not compatible with projects with multiple CSS files at the end of brunch build -P
, since it overwrites all CSS files. Works fine if only one compiled CSS file is present.
P.S. csspath and htmlroot seem to be unnecessary.
Example of @jakubburkiewicz three steps" directories structure: https://github.com/jakubburkiewicz/brunch-scab
hi, thanks for this brunch plugin.
can't seem to get it running however. Disclaimer: I never used uncss before in any setting (grunt,...).
my site structure is as follows (including the built directory
public
):Assuming uncss-brunch runs solely on the command
brunch build -production
, how should I configure the plugin when: I use LESS my distribution directory is/public
my final compiled/built CSS file is located in/public/stylesheets
my brunch setup concatenates css files from thevendor/
folder with my main compiled style.less fileI'm trying this configuration, but it doesnt work.
perhaps I'm getting the mechanics of the plugin wrong?