@jekanok

Tailwind не понимает @apply?

Привет, хотел обновить tailwind на проект, (была другая проблема, немого найти цвет 700 я её исправил) хотел запустить, а там ошибка такого характера (скриншот кода удалён модератором. )

Хотя у меня это шрифт работал, когда я его убираю то идет дальше по строке и говорит что не нашёл цвет и так далее

@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  body {
    @apply font-montserrat font-regular text-base bg-gray-50;
  }
  *,
......


{
  "name": "stadioum",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate",
    "lint:js": "eslint --ext \".js,.ts,.vue\" --ignore-path .gitignore .",
    "lint:prettier": "prettier --check .",
    "lint": "yarn lint:js && yarn lint:prettier",
    "lintfix": "prettier --write --list-different . && yarn lint:js --fix"
  },
  "dependencies": {
    "@nuxtjs/auth": "^4.9.1",
    "@nuxtjs/auth-next": "5.0.0-1648802546.c9880dc",
    "@nuxtjs/axios": "^5.13.6",
    "@nuxtjs/i18n": "^7.2.2",
    "@nuxtjs/robots": "^2.5.0",
    "@nuxtjs/sitemap": "^2.4.0",
    "core-js": "^3.19.3",
    "lodash": "^4.17.21",
    "moment": "^2.29.4",
    "nuxt": "^2.15.8",
    "tailwind-theme-switcher": "^1.0.2",
    "vue": "^2.6.14",
    "vue-plugin-load-script": "^2.1.1",
    "vue-server-renderer": "^2.6.14",
    "vue-socket.io": "3.0.2",
    "vue-template-compiler": "^2.6.14",
    "vuelidate": "^0.7.7",
    "webpack": "^4.46.0"
  },
  "devDependencies": {
    "@babel/eslint-parser": "^7.16.3",
    "@nuxt/postcss8": "^1.1.3",
    "@nuxt/types": "^2.15.8",
    "@nuxt/typescript-build": "^2.1.0",
    "@nuxtjs/eslint-config-typescript": "^8.0.0",
    "@nuxtjs/eslint-module": "^3.0.2",
    "@nuxtjs/moment": "^1.6.1",
    "@nuxtjs/tailwindcss": "^5.3.0",
    "@tailwindcss/aspect-ratio": "^0.4.0",
    "@tailwindcss/forms": "^0.5.2",
    "@tailwindcss/line-clamp": "^0.4.0",
    "@tailwindcss/typography": "^0.5.4",
    "@types/lodash": "^4.14.182",
    "autoprefixer": "^10.4.7",
    "css-loader": "^6.7.1",
    "eslint": "^8.4.1",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-nuxt": "^3.1.0",
    "eslint-plugin-vue": "^8.2.0",
    "postcss": "^8.4.14",
    "postcss-custom-properties": "^12.1.8",
    "postcss-import": "14.0.2",
    "postcss-loader": "5.3.0",
    "postcss-nested": "^5.0.6",
    "postcss-nesting": "^10.1.10",
    "postcss-url": "^10.1.3",
    "prettier": "^2.5.1",
    "sass": "^1.53.0",
    "sass-loader": "^10.3.1",
    "tailwind-config-viewer": "^1.7.1",
    "tailwindcss": "^3.1.6"
  },
  "peerDependencies": {
    "chalk": "^3.0.0",
    "consola": "^2.15.0"
  }
}


export default {
  // Global page headers: https://go.nuxtjs.dev/config-head
  head: {
    title: 'stadioum',
    htmlAttrs: {
      lang: 'en',
    },
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' },
      { name: 'format-detection', content: 'telephone=no' },
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
      {
        rel: 'stylesheet',
        href: 'https://fonts.googleapis.com/css2?family=Montserrat:wght@500;600;700&display=swap',
      },
    ],
  },
  // Global CSS: https://go.nuxtjs.dev/config-css
  css: ['@/assets/css/tailwind.css'],
  devServerHandlers: [],

  // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  plugins: [],

  // Auto import components: https://go.nuxtjs.dev/config-components
  components: true,

  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  buildModules: [
    '@nuxt/postcss8',
    // https://go.nuxtjs.dev/typescript
    '@nuxt/typescript-build',
    // https://go.nuxtjs.dev/tailwindcss
    '@nuxtjs/tailwindcss',
    '@nuxtjs/moment',
  ],

  // Modules: https://go.nuxtjs.dev/config-modules
  modules: [
    // https://go.nuxtjs.dev/axios
    '@nuxtjs/axios',
    '@nuxtjs/tailwindcss',
  ],

  // Axios module configuration: https://go.nuxtjs.dev/config-axios
  axios: {
    // Workaround to avoid enforcing hard-coded localhost:3000: https://github.com/nuxt-community/axios-module/issues/308
    baseURL: '/',
  },

  // Build Configuration: https://go.nuxtjs.dev/config-build
  build: {
    postcss: {
      plugins: {
        tailwindcss: {},
        autoprefixer: {},
      },
    },
  },
}


Спасибо за ответ)
  • Вопрос задан
  • 378 просмотров
Пригласить эксперта
Ответы на вопрос 1
@fillAisen
В документации Tailwind не рекомендуется использовать @apply т.к. каждый тег в vue компонентах компилируется независимо от всех остальных файлов CSS , рекомендуется использовать tailwind.config,cjs и его директиву plugins

https://tailwindcss.com/docs/functions-and-directi...
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы