Skip to content

Instantly share code, notes, and snippets.

@wojtekmaj
Last active July 16, 2024 17:39
Show Gist options
  • Save wojtekmaj/41b0724cbb81b8ab740d5ee403dbc2ec to your computer and use it in GitHub Desktop.
Save wojtekmaj/41b0724cbb81b8ab740d5ee403dbc2ec to your computer and use it in GitHub Desktop.
Visual Studio Code-compatible regular expression to add all missing import extensions
# Find
import\s(([^;]|\n)*)\sfrom\s(['"])(\.{1,2}\/.*)(?<!\.js)(?<!\.(css|pdf|png|jpg|jsx|mjs|mp3|mp4|svg|ttf))(?<!\.(avif|json|webm|webp|woff))(?<!\.woff2)(['"]);
# Replace with
import $1 from $3$4.js$7;
@Mikescops
Copy link

Excellent thanks, it also works well for export 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment