我有一个项目,我使用 Django 作为 css 的后端和尾风。 tailwind 没有给我任何错误,并且在我的文件中查找类,但不生成 css。它唯一适用的类是 bg-blue-500,仅此而已。如果有人能想到为什么会发生这种情况或如何解决,我将非常感激。
html页面
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<title>{% block title %}Auctions{% endblock %}</title>
<link rel="stylesheet" href="{% static 'auctions/output.min.css' %}">
</head>
<body>
<h1>Auctions</h1>
<div>
{% if user.is_authenticated %}
Signed in as <strong>{{ user.username }}</strong>.
{% else %}
Not signed in.
{% endif %}
</div>
<ul class="nav">
<li class="nav-item bg-red-500">
<a class="nav-link" href="{% url 'activeListings' %}">Active Listings</a>
</li>
{% if user.is_authenticated %}
<li class="nav-item bg-blue-500">
<a class="nav-link" href="{% url 'logout' %}">Log Out</a>
</li>
{% else %}
<li class="nav-item">
<a class="nav-link" href="{% url 'login' %}">Log In</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'register' %}">Register</a>
</li>
{% endif %}
</ul>
<hr>
{% block body %}
{% endblock %}
</body>
</html>
顺风.css
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
h1 {
@apply text-4xl;
}
h2 {
@apply text-3xl;
}
h3 {
@apply text-2xl;
}
h4 {
@apply text-xl;
}
}
包.json
{
"name": "jstools",
"version": "1.0.0",
"description": "",
"main": "tailwind.config.js",
"scripts": {
"build": "tailwind build -i ../auctions/tailwind.css -o ../auctions/output.css && cleancss -o ../auctions/output.min.css ../auctions/output.css"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"autoprefixer": "^10.4.12",
"clean-css-cli": "^5.6.1",
"tailwindcss": "^3.1.8"
}
}
顺风配置
/** @type {import('tailwindcss').Config} */
module.exports = {
future: {
removeDeprecatedGapUtilities: true,
purgeLayersByDefault: true,
},
content: {
enabled: false, //true for production build
content: ['../../templates/auctions/*.html', '../../templates/**/*.html']
},
theme: {
screens: {
sm: '640px',
md: '768px',
lg: '1024px',
xl: '1280px'
},
extend: {},
},
variants: {},
plugins: [],
}