๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Vue.js

[Vue.js2 + tailwindcss] build ์„ค์ • ๋ฐฉ๋ฒ•

by devebucks 2022. 2. 10.
728x90

main.js

import Vue from "vue";
import App from "./App.vue";
import "tailwindcss/tailwind.css"; ๐Ÿ‘ˆ
import "@/src/assets/global.css"; ๐Ÿ‘ˆ

new Vue({
  render: (h) => h(App),
}).$mount("#app");

 

tailwind.config.js

module.exports = {
    purge: ['./src/**/*.html', './src/**/*.js'], // ๐Ÿ‘ˆ
    prefix: 'tw-',
    // ...
}

 

postcss.config.js

ํ”„๋กœ์ ํŠธ ํ™ˆ ๊ฒฝ๋กœ์— postcss.config.js ํŒŒ์ผ ์ƒ์„ฑ ํ›„ ๋‹ค์Œ์„ ์ž‘์„ฑ

const autoprefixer = require("autoprefixer");
const tailwindcss = require("tailwindcss");

module.exports = {
  plugins: [autoprefixer, tailwindcss],
};

vue.config.js

module.exports = defineConfig({
  transpileDependencies: true,
  configureWebpack: {
    resolve: {
      alias: {
        "@": path.join(__dirname, "/"),
      },
    },
    module: { ๐Ÿ‘ˆ
      rules: [
        {
          test: /\.css$/,
          use: ["postcss-loader"],
        },
      ],
    },
  },
});

 

 

์ฐธ์‚ฌ

ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

1. vue add tailwind

ํ„ฐ๋ฏธ๋„์— ํ”„๋กœ์ ํŠธ ๊ฒฝ๋กœ์—์„œ ๋‹ค์Œ ๋ช…๋ น์–ด ์ž…๋ ฅ

vue add tailwind

none ์„ค์ •(๋‚˜๋Š” ๊ธฐ์กด์— ์‚ฌ์šฉํ•˜๋˜ tailwind.config.js๊ฐ€ ์žˆ์Œ.)

 > src/assets/tailwind.css๊ฐ€ ์ž๋™์œผ๋กœ ์ƒ์„ฑ๋จ.

 

 

2. ๊ธฐ์กด์— ์žˆ๋Š” tailwind.config.js์— ๋‹ค์Œ ์„ค์ • ๋ณ€๊ฒฝ

module.exports = {
    purge: ['./src/**/*.html', './src/**/*.{js,ts,vue}'], // ๐Ÿ‘ˆ
    prefix: 'tw-',
    // ...
}

3. ./src/main.ts

import '@/assets/tailwind.css';
// ...

 

 

๊ฒฐ๊ณผ ํ™•์ธ

728x90

๋Œ“๊ธ€