It actually is the last mile that matters. When shipped half way around the world it's in bulk. The amount of fuel per unit of food is surprisingly low.
For the last mile you're not getting 100 meals delivered even though they would fit in the car. The fuel to food ratio is insane for 1 meal.
Of course buying local is better when you have the option, but it doesn't make nearly as much of a difference as last mile delivery.