๐ yarn add node-sass sass loader๋ฅผ ์ค์นํด์ฃผ์ด์ผ Sass๋ฅผ ์ฌ์ฉ์ด ๊ฐ๋ฅํ๋ค.
๐งจ์ฃผ์ : Error: Node Sass version 5.0.0 is incompatible with ^4.0.0. ์ด๋ฌํ ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ฉด Node Sass์ ๋ฒ์ ์ด ๋ง์ง ์๋ค๋ ๊ฒ.
- npm uninstall node-sass
- npm install node-sass@4.14.1 ๋ฅผ ์ฌ์ฉํ์ฌ ํด๊ฒฐํด์ค.
- ๋ญํด๋ ์๋๋ฉด nodejs๋ฅผ ์ง์ ๋ค๊ฐ LTS๋ฒ์ ์ผ๋ก ๋ค์ ์ค์นํ๋ ๊ฒ์ ์ถ์ฒ
ํ์๋ ๊ทธ๋ ๊ฒ ํด๊ฒฐ. 3์๊ฐ ์ฝ์ง..
ํน์ ํด๋์ค์ ๋ง์ฐ์ค๋ฅผ ์ฌ๋ฆด ๋๋ ํด๋ฆญํ ๋ ๋ค๋ฅธ ์คํ์ผ ์ ์ฉํ๋ CSS ์ฝ๋.
.box:active{ background:red; .box:active{ background:yellow;
โฌ
Sass์ ํ์ฌ ์ ํ์ ์ฐธ์กฐ ๊ธฐ๋ฅ์ผ๋ก ์์ฑ.
.box{ &:hover{ background: red; } &:active{ background:yellow; } }
render(){
const isBlue=true;
return(
<div className={cx('box', {
blue:isBlue
})}>
<div className={cx('box-inside')}/>
</div>
);
}
Sass๋ ์์ฃผ ์ฌ์ฉํ๋ ๊ฐ์ ๋ณ์์ ๋ฃ์ ์ ์๋ค.
$size: 100px;
.box{
display : inline-block;
width : $size;
height: $size;
}
์์ฃผ ์ฌ์ฉํ๋ ๊ฐ -> ๋ณ์
์์ฃผ ์ฌ์ฉํ๋ ๊ตฌ๋ฌธ -> ๋ฏน์ค์ธ
$size : 100px;
@mixin place-at-center(){
top:50%;
left:50%;
transform: translate(-50%,-50%);
}
.box{
display : inline-block;
width: $size;
height : &size;
@include place-at-center();
}
๐ ์์์ ๋ฐฐ์ด ๋ณ์์ ๋ฏน์ค์ธ์ ์ฌ๋ฌ ๊ณณ์์ ์ฌ์ฉํด์ผ ํ๊ธฐ ๋๋ฌธ์ ์คํ์ผ ๋๋ ํ ๋ฆฌ๋ฅผ ๋ง๋ค์ด ์ ์ญ์ ์ผ๋ก ์ฌ์ฉํ๋ ์ฝ๋๋ฅผ ๋ฐ๋ก ๋ถ๋ฆฌ.
$size : 100px;
@mixin place-at-center(){
top:50%;
left:50%;
transform: translate(-50%,-50%);
}
@import './styles/utils';
๐ Sass ์ฅ์ ์ค ํ๋๋ ์คํ์ผ ๊ด๋ จ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฝ๊ฒ ๋ถ๋ฌ์ ์ฌ์ฉํ ์ ์๋ค๋ ์ .
์ฌ์ฉํ๊ธฐ ์ํด์๋ ๋ฐ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ค์น
npm or yarn์ผ๋ก ์ค์นํ ํจํค์ง ๋ด๋ถ์ ํ์ผ์ ๋ถ๋ฌ์ฌ ๋๋ ~๋ฌธ์๋ฅผ ์ฌ์ฉํด์ node_modules์ ์ ๊ทผ ๊ฐ๋ฅ.
- yarn add include-media open-color
์ฐธ๊ณ : <๋ฆฌ์กํธ๋ฅผ ๋ค๋ฃจ๋ ๊ธฐ์ >