“Vanity of vanities, saith the Preacher, vanity of vanities; all is vanity.” (Ecclesiastes 1:2)
“All” refers to “all created things” as only the Creator Himself (God) is “not” of vanity.
Hence, only a life rooted in God will prove “not” vain.
Here’s a verse which proves the Biblical usage (context) that “all” always refers to “all creation” but “never God” (as He is excepted from it – being the only One above all):
“for all things He did put under His feet, and, when one may say that all things have been subjected, it is evident that He is excepted Who did subject the all things to Him,” (1 Corinthians 15:27)