์ด๊ฒ์ ์๋ํฉ๋๋ค
import Component from '../component.jsx';
์ค๋ฅ ๋ฐ์
import Component from '/client/modules/account_details/components/component.jsx';
Module not found: Error: Cannot resolve 'file' or 'directory'
๋ด ๊ตฌ์ฑ ์์ ์ค ์ผ๋ถ์๋ import ๋ฌธ์ ์ ๋ ๊ฒฝ๋ก๊ฐ ์์ผ๋ฉฐ ์ด๋ก ์ธํด ์ด์ผ๊ธฐ๊ฐ ์ค๋จ๋ฉ๋๋ค. ../../../../
๋ฑ์ ์ํํ๋ ๊ฒ ์ธ์ ํด๊ฒฐ ๋ฐฉ๋ฒ์ด ์์ต๋๊น?
https://github.com/mantrajs/babel-root-slash-import๋ฅผ ์ฌ์ฉํด ๋ณด์์ง๋ง
ํด๋น ํจํค์ง์ .babelrc
ํ์ผ์ ์ถ๊ฐํ ํ Uncaught SyntaxError: Unexpected token import
๋ฌธ์
{
"plugins": [
"babel-root-slash-import"
]
}
๋ก ์ด๊ฒ์ ํด๊ฒฐํ ์ ์์๋ค
{
"presets": ["es2015", "react"],
"plugins": [
"babel-root-slash-import"
]
}
{
"presets": ["es2015", "react"],
"plugins": [
[
"babel-root-slash-import", {
"rootPathSuffix": "src/"
}
]
]
}
์ด ๊ฐ์?
์ด๊ฒ์ ์๋ํ์ง ์๊ธฐ ๋๋ฌธ์
๋ํ ์ด๊ฒ์ ๋ฐ์ ์ฑ ์์ฑ์์ .babelrc์ ๊ธฐ๋ณธ ๊ตฌ์ฑ์ ์ฌ์ ์ํฉ๋๊น?