yarn create vite
yarn create vite dfesta --template react-ts
yarn set version berry
yarn install
yarnPath: .yarn/releases/yarn-3.6.1.cjs
nodeLinker: pnp
yarn install
# Zero-Install을 사용
.yarn/*
!.yarn/cache
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
yarn dlx @yarnpkg/sdks vscode
는 Yarn을 사용하여 @yarnpkg/sdks
라는 패키지를 다운로드하고, 해당 패키지에 포함된 vscode
라는 스크립트를 실행하는 것을 의미한다. 이것은 VSCode 관련 도구를 사용하기 위해 필요한 도구를 가져와서 실행하는 것이다.
yarn dlx @yarnpkg/sdks vscode
dev server 실행 시, node_modules가 생성되는 것을 원치 않는다면 vite.config.ts에 아래와 같이 cacheDir을 설정해준다.
vite.config.ts
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
cacheDir: './.vite',
})
.gitignore
...
.vite
sass를 설치해서 사용하면 된다.
yarn add sass -D
CSS 모듈처럼 사용하려면 파일 확장자에 .module만 붙여주면 된다.
Loading.module.scss
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
...
resolve: {
alias: {
'@': '/src',
},
},
})
{
"compilerOptions": {
"baseUrl": "./src",
"paths": {
"@/*": [
"./*"
],
},
....
}
yarn add recoil -D
import React from 'react';
import ReactDOM from 'react-dom';
import { RecoilRoot } from 'recoil';
import App from './App';
ReactDOM.render(
<RecoilRoot>
<App />
</RecoilRoot>,
document.getElementById('root')
);
import { atom } from 'recoil';
export const testState = atom({
key: 'testState',
default: 'test',
});
import React from 'react';
import classNames from 'classnames/bind';
import styles from './Home.module.scss';
import { useRecoilValue } from 'recoil'
import { testState } from '@/recoil/test';
const cx = classNames.bind(styles);
const Home: React.FC = () => {
const test = useRecoilValue(testState)
console.log(test)
return (
<div className={cx('home')}>
Home
</div>
)
}
export default Home;
정보 감사합니다.