与Laravel Jetstream一起使用时,顺风颜色无法编译 [英] Tailwind Colors not compiling when used with Laravel Jetstream
本文介绍了与Laravel Jetstream一起使用时,顺风颜色无法编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我安装了Laravel Jetstream并使用顺风CSS,但是使用顺风组件时默认颜色不起作用。
我只想使用默认颜色,还不想使用自定义颜色。
trawind.config.js
const defaultTheme = require('tailwindcss/defaultTheme');
module.exports = {
mode: 'jit',
purge: [
'./vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php',
'./vendor/laravel/jetstream/**/*.blade.php',
'./storage/framework/views/*.php',
'./resources/views/**/*.blade.php',
],
theme: {
extend: {
fontFamily: {
sans: ['Nunito', ...defaultTheme.fontFamily.sans],
},
},
},
plugins: [require('@tailwindcss/forms'), require('@tailwindcss/typography')],
};
Jetstream随TailWind 2.2.2一起安装,该版本存在此问题。我已尝试降级到2.0.2,这是已知对我有效的最新版本,但这也显示出问题
使用相同的HTML代码时,在使用顺风2.0.2安装的Laravel Breeze中使用时,确实可以正常工作。
示例html
<div class="flex-shrink-0 flex items-center justify-center w-16 bg-pink-600 text-white text-sm font-medium rounded-l-md">
</div>
Package.json
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production"
},
"devDependencies": {
"@tailwindcss/forms": "^0.3.1",
"@tailwindcss/typography": "^0.4.0",
"alpinejs": "^3.0.6",
"axios": "^0.21",
"laravel-mix": "^6.0.6",
"lodash": "^4.17.19",
"postcss": "^8.1.14",
"postcss-import": "^14.0.1",
"tailwindcss": "^2.2.2"
},
"dependencies": {
"daisyui": "^1.13.2"
}
}
在上面的示例中,BG-PINK-600未呈现。
推荐答案
您必须在tailwind.config.js
文件中添加所需的特定颜色,TailwindCSS palette如下所示:
trawind.config.js
const defaultTheme = require('tailwindcss/defaultTheme');
const colors = require('tailwindcss/colors');
module.exports = {
mode: 'jit',
purge: [
'./vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php',
'./vendor/laravel/jetstream/**/*.blade.php',
'./storage/framework/views/*.php',
'./resources/views/**/*.blade.php'
],
theme: {
colors: {
transparent: 'transparent',
current: 'currentColor',
//amber: colors.amber,
black: colors.black,
blue: colors.blue,
cyan: colors.cyan,
emerald: colors.emerald,
fuchsia: colors.fuchsia,
gray: colors.trueGray,
blueGray: colors.blueGray,
coolGray: colors.coolGray,
//trueGray: colors.trueGray,
warmGray: colors.warmGray,
green: colors.green,
indigo: colors.indigo,
lime: colors.lime,
orange: colors.orange,
pink: colors.pink,
purple: colors.purple,
red: colors.red,
rose: colors.rose,
sky: colors.sky,//warn - As of Tailwind CSS v2.2, `lightBlue` has been renamed to `sky`.
teal: colors.teal,
violet: colors.violet,
yellow: colors.amber,
white: colors.white,
},
extend: {
fontFamily: {
sans: ['Nunito', ...defaultTheme.fontFamily.sans],
},
},
},
plugins: [require('@tailwindcss/forms'), require('@tailwindcss/typography')],
};
提示
您实际上可以检查node_modules/tailwindcss/colors.js
文件中可用的默认颜色。
选择颜色并保存文件后,现在再次运行
npm run dev
现在刷新Web浏览器的缓存并重新加载页面(您可能需要重新登录到您的Laravel应用程序)
这篇关于与Laravel Jetstream一起使用时,顺风颜色无法编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文