unimported
unimported copied to clipboard
Unable to import images
This tools awesome to check all my unused files, but i have some import file that used package.json
alias name
with something like this:
let say i have this structure folder
assets (dir)
welcome.webp
splash_screen.png
package.json
index.js (file)
where package.json
inside assets
folder has json :
{
"name": "@images"
}
and my index.js
contain some code like this :
const WelcomeImage = require('@images/welcome.webp')
when i run npx unimported --no-cache
i got an error
Failed parsing ~/cwd/assets/welcome.webp
is there something wrong with my unimported
config?
.unimportedrc.json
{
"ignorePatterns": [
"**/node_modules/**",
"**/*.tests.{js,jsx,ts,tsx}",
"**/*.test.{js,jsx,ts,tsx}",
"**/*.spec.{js,jsx,ts,tsx}",
"**/tests/**",
"**/__tests__/**",
"**/*.d.ts"
],
"entry": ["index.js"],
"aliases": {
"@images/*": ["assets/", "assets/*"]
},
"extensions": [".js", ".jsx", ".ts", ".tsx", ".webp", ".jpg", ".png"],
"ignoreUnimported": [],
"ignoreUnused": [
"react",
"react-dom",
"react-native"
],
"ignoreUnresolved": []
}
We can't parse images, and that's what you're trying to import with require('@images/welcome.web')
.
will you add this feature @smeijer ?
Closing, see #91