运行环境
node和npm使用版本
node v14.21.3 (npm v6.14.18)
1.插件下载
官方文档说明
npm install -D @nuxtjs/tailwindcss@3.4.3 tailwindcss@3.4.1 postcss@^8.4.33 autoprefixer@10.4.17
2.nuxt.config.js配置
module.exports = {
// ...
buildModules: ['@nuxtjs/tailwindcss'],
// ...
}
3.tailwind.config.js
npx tailwindcss init文章来源:https://www.toymoban.com/news/detail-821136.html
module.exports = {
future: {
// removeDeprecatedGapUtilities: true,
// purgeLayersByDefault: true,
},
purge: [
'./components/**/*.{vue,js}',
'./layouts/**/*.vue',
'./pages/**/*.vue',
],
theme: {
extend: {},
},
variants: {},
plugins: [],
}
4.全局引入css
创建全局css文件
/assets/css/xxx.css文章来源地址https://www.toymoban.com/news/detail-821136.html
// xxx.css
@tailwind base;
@tailwind components;
@tailwind utilities;
配置nuxt.config.js
module.exports = {
// ...
css: [
// ...
'~assets/css/xxx.css',
],
// ...
}
package.json插件版本
"dependencies": {
"nuxt": "^2.14.7",
"vue": "^2.6.12",
},
"devDependencies": {
"@nuxtjs/tailwindcss": "^3.4.3",
"autoprefixer": "^10.4.17",
"node-sass": "^4.14.1",
"postcss": "^8.4.33",
"sass-loader": "^8.0.0",
"tailwindcss": "^3.4.1"
}
到了这里,关于「nuxt2配置tailwindcss」nuxt2添加tailwindcss详细步骤!解决版本不对称各种报错~~复制黏贴搞定!的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!