1) Node.js ์ค์น ๋ฐ ์ด๊ธฐํ
- Node.js ์ต์ ์ค์น : ๐ brew install node
- Node.js ํน์ ์ค์น : ๐ brew install node@12
- Node.js ์ค์น ํ์ธ : ๐ node -v
- Node.js ์ด๊ธฐํ : ๐ npm init ๐ package.json ํ์ผ์ด ์์ฑ๋์!
{
"name": "airbnb-clone",
"version": "1.0.0",
"description": "Cloning Airbnb with Python, Django, Tailwind and more...",
"repository": {
"type": "git",
"url": "git+https://github.com/Jang-Jaewon/airbnb-clone.git"
},
"scripts": {
"css": "gulp"
},
"homepage": "https://github.com/Jang-Jaewon/airbnb-clone#readme",
"devDependencies": {
"autoprefixer": "^9.7.0",
"gulp": "^4.0.2",
"gulp-csso": "^3.0.1",
"gulp-postcss": "^8.0.0",
"gulp-sass": "^4.0.2",
"node-sass": "^4.13.0",
"tailwindcss": "^1.1.3"
}
}
4) "gulpfile.js" ๋ฐ "styles.scss" ์์ฑ
- ํ๋ก์ ํธ ๋๋ ํ ๋ฆฌ ์์ "gulpfile.js" ํ์ผ์ ๋ง๋ค์ด์ค ๋ค, ์๋ ๋ด์ฉ์ ๋ถ์ฌ๋ฃ๊ธฐ ํฉ๋๋ค.
const gulp = require("gulp");
const css = () => {
const postCSS = require("gulp-postcss");
const sass = require("gulp-sass");
const minify = require("gulp-csso");
sass.compiler = require("node-sass");
return gulp
.src("assets/scss/styles.scss",{allowEmpty: true})
.pipe(sass().on("error", sass.logError))
.pipe(postCSS([require("tailwindcss"), require("autoprefixer")]))
.pipe(minify())
.pipe(gulp.dest("static/css"));
};
exports.default = css;
- ํ๋ก์ ํธ ๋๋ ํ ๋ฆฌ ๋ด์ "assets/scss/styles.scss" ๋๋ ํ ๋ฆฌ ๋ฐ ํ์ผ์ ์์ฑ ํ ์๋ ๋ด์ฉ์ ์ถ๊ฐํฉ๋๋ค.
@tailwind base;
@tailwind components;
@tailwind utilities;
- "npm run i", "npm run css"๋ฅผ console์ ์
๋ ฅํ์ ๋, ์๋์ฒ๋ผ ์ค๋ฅ๊ฐ ์์ผ๋ฉด ์ ์์
๋๋ค.
- ์ ์์ ์ผ๋ก setting ๋์๋ค๋ฉด, static ๋๋ ํ ๋ฆฌ์ cssํ์ผ์ด ์์ฑ๋ ๊ฒ์ ํ์ธํ ์:)
- ๋ชจ๋ ์์
์ "assets/scss/styles.scss"์์ ์ํํ๊ณ , "staic/css/styles.css"์ ๊ฑด๋๋ฆฌ์ง ์์ต๋๋ค. "gulpfile.js"์์ css๋ก ๋ณํํด์ฃผ๊ธฐ ๋๋ฌธ์ด์์!
- ๋ํ "assets/scss/styles.scss"์ ๋ณ๊ฒฝ์ด ์์ ๋ ๋ง๋ค "npm run css" ๋ช
๋ น์ ํด์ฃผ์ด์ผ ํด์. "npm run css"๋ "styles.scss"์ ๊ฐ๋ฅผ ์น๋ธ๋ผ์ฐ์ ๊ฐ ์ดํดํ ์ ์๊ฒ CSS๋ก ๋ณ๊ฒฝํด์ฃผ๋ ๋ช
๋ น์
๋๋ค.