tailwindInstallOnVue - PEACH-BROS/lets-merge GitHub Wiki
Vue์ Tailwind ์ ์ฉํ๊ธฐ
์์
ํ๋ก์ ํธ ์์ฑ
vue ํ๋ก์ ํธ ๋ง๋ค๊ธฐ (vue-cli ๋ฒ์ 3 ์ด์) vue create [project ์ด๋ฆ]
cd [project ์ด๋ฆ]
tailwindcss ์ค์น ๋ฐ ์ ์ฉ
tailwindcss ์ค์น npm install tailwindcss
/* src/assets/css/tailwind.css */
@tailwind base;
@tailwind components;
@tailwind utilities;
// src/main.js
...
import "@/assets/css/tailwind.css";
...
project root dir ์์ npx tailwindcss init --full
tailwind.config.js ์ ์ํ๋ ํ๋ฌ๊ทธ์ธ,ํ
๋ง ๋ฑ ์ถ๊ฐ ๊ฐ๋ฅ
// /postcss.config.js
const autoprefixer = require('autoprefixer')
const tailwindcss = require('tailwindcss')
module.exports = {
plugins: [autoprefixer, tailwindcss]
}
ํ์ผ ์ฌ์ด์ฆ ์ค์ด๊ธฐ
npm install @fullhuman/postcss-purgecss --save-dev
// postcss.config.js ๋ฅผ ์์ ํ๋ค.
const autoprefixer = require('autoprefixer')
const tailwindcss = require('tailwindcss')
const purgecss = require('@fullhuman/postcss-purgecss')({
// Specify the paths to all of the template files in your project
content: [
'./src/**/*.html',
'./src/**/*.vue',
'./src/**/*.jsx',
// etc.
],
// This is the function used to extract class names from your templates
defaultExtractor: content => {
// Capture as liberally as possible, including things like `h-(screen-1.5)`
const broadMatches = content.match(/[^<>"'`\s]*[^<>"'`\s:]/g) || []
// Capture classes within other delimiters like .block(class="w-1/2") in Pug
const innerMatches = content.match(/[^<>"'`\s.()]*[^<>"'`\s.():]/g) || []
return broadMatches.concat(innerMatches)
}
})
module.exports = {
plugins: [
autoprefixer,
tailwindcss,
...process.env.NODE_ENV === 'production'
? [purgecss]
: []
]
}