Let $(X_i)_{i\in\mathbb{Z}^d_+}$ be an array of zero-mean independent identically distributed random vectors with values in $\mathbb{R}^k$ with finite variance, and let $\mathscr{L}$ be a class of Borel subsets of $\lbrack 0, 1\rbrack^d$. If, for the usual metric, $\mathscr{L}$ is totally bounded and has a convergent entropy integral, we obtain a strong invariance principle for an appropriately smoothed version of the partial-sum process $\{\sum_{i\in\nu S} X_i: S \in \mathscr{L}\}$ with an error term depending only on $\mathscr{L}$ and on the tail distribution of $X_1$. In particular, when $\mathscr{L}$ is the class of subsets of $\lbrack 0, 1\rbrack^d$ with $\alpha$-differentiable boundaries introduced by Dudley, we prove that our result is optimal.