Simplify plugin for safer transforms

- Use JSON.stringify instead of manually escaping, closes #1
- Use Array.indexOf to check for (case-insensitive) file extension, closes #2