使用 Tailwindcss 时浏览器不会自动更新
<p>每次我添加一个类时,要查看更改,我必须停止运行 nuxt,重新加载 VS Code 窗口并再次运行“npm run dev”。然后我就可以看到变化</p>
<p>我的 tailwind.config.js :</p>
<p>
<pre class="brush:js;toolbar:false;">/**@type {import('tailwindcss').Config}*/
module.exports = {
content: [
'./components/**/*.{js,vue,ts}',
'./布局/**/*.vue',
'./pages/**/*.vue',
'./插件/**/*.{js,ts}',
'./nuxt.config.{js,ts}'
],
theme: {
extend: {}
},
plugins: [require('daisyui')]
}</pre>
</p>
<p>我将 tailwind.css 文件放在 assets/css/tailwind.css 中</p>
<p>并将其导入到我的布局组件中:layouts/default.vue</p>
<p>我的 nuxt.config.ts:</p>
<p>
<pre class="brush:js;toolbar:false;">// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
css: ['~/assets/css/tailwind.css'],
build: {
postcss: {
postcssOptions: {
plugins: {
tailwindcss: {},
autoprefixer: {}
}
}
}
}
})</pre>
</p>
<p>我的package.json:</p>
<pre class="brush:json;toolbar:false;">{
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
},
"devDependencies": {
"nuxt": "3.0.0-rc.11",
"tailwindcss": "^3.1.8"
},
"dependencies": {
"daisyui": "^2.31.0",
"firebase": "^9.10.0"
}
}
</pre></p>