CRA로 만든 앱에서 절대경로로 import 해오기(alias하기)
Last updated
Last updated
const path = require('path');
module.exports = {
webpack: {
alias: {
'@': path.resolve(__dirname, 'src/'),
'@components': path.resolve(__dirname, 'src/components'),
'@shared': path.resolve(__dirname, 'src/components/shared'),
'@constants': path.resolve(__dirname, 'src/constants'),
'@views': path.resolve(__dirname, 'src/views'),
},
},
};/* package.json */
"scripts": {
- "start": "react-scripts start",
+ "start": "craco start",
- "build": "react-scripts build",
+ "build": "craco build"
- "test": "react-scripts test",
+ "test": "craco test"
}...
import Template from '@shared/Template/Template';
...