安装Tailwind CSS v2.0和x2B;into Laravel 8可以工作,但运行时什么也不做
我试图将Tailwind CSS v2.0安装到一个干净的Laravel安装中,但是当我运行安装Tailwind CSS v2.0和x2B;into Laravel 8可以工作,但运行时什么也不做,laravel,webpack,tailwind-css,postcss,Laravel,Webpack,Tailwind Css,Postcss,我试图将Tailwind CSS v2.0安装到一个干净的Laravel安装中,但是当我运行npm run prod(或dev)时,编译的CSS文件只是源代码的一个副本 我正在采取的步骤: > laravel new twtest > cd twtest > php artisan -V # Laravel Framework 8.16.1 > npm install > npm install tailwindcss postcss autoprefixer &g
npm run prod
(或dev
)时,编译的CSS文件只是源代码的一个副本
我正在采取的步骤:
> laravel new twtest
> cd twtest
> php artisan -V
# Laravel Framework 8.16.1
> npm install
> npm install tailwindcss postcss autoprefixer
> touch postcss.config.js
# Add the postCss default from https://tailwindcss.com/docs/installation
# Add the three @tailwind commands into /resources/css/app.css
> npm run dev
这将成功编译,但输出CSS(在public/CSS/app.CSS
中)列出了相同的三个tailwind命令,其中应包含所有已编译的tailwind CSS:
@tailwind base;
@tailwind components;
@tailwind utilities;
使用以下工具确保您拥有最新版本:
npm install -D laravel-mix@latest tailwindcss@latest postcss@latest autoprefixer@latest --save-dev
仔细检查package.json是否包含支持最新版本Laravel Mix的最新脚本条目
"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"
},
另外,删除postss.config.js并在生成postss.config.js的同时生成tailwind.config.js
npx tailwindcss init -p
将以下内容添加到/resources/css/app.css中
@tailwind base;
@tailwind components;
@tailwind utilities;
完整的步骤将是:
laravel new twtest
cd twtest
npm install -D laravel-mix@latest tailwindcss@latest postcss@latest autoprefixer@latest --save-dev
npx tailwindcss init
# Add the three @tailwind entries into /resources/css/app.css
npm run prod