Hi,
Kind of duplicate of this topic and this one about MBED 6 compile time.
To get .mbedignore
properly apply to your project, you have to either copy directly to the mbed framework folder used by PIO, or use this external script (which seems to be the best solution right now).
Another solution is to use bare metal profile adding this file to your PIO project.