当前位置: 首页 > news >正文

TailWindCss 在Hbuilderx中使用

基于这个插件 weapp-tailwindcss

地址

本次说明基于HbuilderX 创建的项目非CLI

安装步骤按照文档走,先安装上几个依赖。然后是几个配置文件

tailwind-input.css tailwind的css文件用来引入到app.vue


/* #ifdef H5 */
@tailwind base;  /* 如果是小程序的话,这一行注释掉,因为tailwind base模块提供的一些样式选择器是基于*,这在小程序中会报错 */  
/* #endif */@tailwind components;  
@tailwind utilities;

tailwind.config.js tailwind 的配置文件

const path = require("path");
const resolve = (p) => {return path.resolve(__dirname, p);
};
/** @type {import('tailwindcss').Config} */
module.exports = {content: ['./index.html', './**/*.{html,vue}'].map(resolve),theme: {extend: {colors: {white: '#ffffff',black: '#000000',main: '#333333',content: '#666666',muted: '#999999',light: '#e5e5e5',primary: {DEFAULT: '#4173ff'},success: '#5ac725',warning: '#f9ae3d',error: '#f56c6c',info: '#909399',page: '#f6f6f6'},fontSize: {xs: '24rpx',sm: '26rpx',base: '28rpx',lg: '30rpx',xl: '32rpx','2xl': '34rpx','3xl': '38rpx','4xl': '40rpx','5xl': '44rpx'}},},plugins: [],corePlugins: {// 不需要 preflight,因为这主要是给 h5 的,如果你要同时开发小程序和 h5 端,你应该使用环境变量来控制它preflight: false}
}

vite.config.js 目下没有的需要手动创建下

import path from "path";
import { defineConfig } from "vite";
import uni from "@dcloudio/vite-plugin-uni";
import { UnifiedViteWeappTailwindcssPlugin as uvwt } from "weapp-tailwindcss/vite";
// 注意: 打包成 h5 和 app 都不需要开启插件配置
const isH5 = process.env.UNI_PLATFORM === "h5";
const isApp = process.env.UNI_PLATFORM === "app";
const WeappTailwindcssDisabled = isH5 || isApp;
// vite 插件配置
const vitePlugins = [uni(), uvwt({disabled: WeappTailwindcssDisabled
})];const resolve = (p) => {return path.resolve(__dirname, p);
};const postcssPlugins = [require("autoprefixer")(),require("tailwindcss")({config: resolve("./tailwind.config.js"),}),
];
if (!WeappTailwindcssDisabled) {postcssPlugins.push(require("postcss-rem-to-responsive-pixel")({rootValue: 32,propList: ["*"],transformUnit: "rpx",}));
}
// https://vitejs.dev/config/
export default defineConfig({plugins: vitePlugins,// 假如 postcss.config.js 不起作用,请使用内联 postcss Latsetcss: {postcss: {plugins: postcssPlugins,},},
});

重新运行下,就可以使用tailwind 的css 类了

http://www.lryc.cn/news/117519.html

相关文章:

  • Unity导入图片时,通过设置属性快速实现资源的压缩
  • AlmaLinux 9 安装 Go 1.20
  • 【Docker】数据库动态授权组件在Kubernetes集群下的测试过程记录
  • 数据结构【第3章】——线性表
  • MySql之分库分表
  • 数据结构—图的遍历
  • MySQL主从复制基于二进制日志的高可用架构指南
  • RestTemplate HTTPS请求忽略SSL证书
  • Jenkins触发器时间、次数设定
  • kafka partition的数据文件(offffset,MessageSize,data)
  • htnl根据轮播图图片切换背景色
  • gpu-manager安装及测试
  • Go和Java实现享元模式
  • Zookeeper特性与节点数据类型详解
  • 函数的递归
  • Android T 窗口层级其二 —— 层级结构树的构建(更新中)
  • ASIC芯片设计全流程项目实战课重磅上线 ,支持 65nm制程流片 !
  • 背上沉重的书包准备run之react篇
  • LAMP及论坛搭建
  • php-cgi.exe - FastCGI 进程超过了配置的请求超时时限
  • linux系统虚拟主机开启支持SourceGuardian(sg11)加密组件
  • 让我们一起探讨汽车充电桩控制主板的应用
  • Gartner发布《2023年全球RPA魔力象限》:90%RPA厂商,将提供生成式AI自动化
  • springboot整合JMH做优化实战
  • 利用ffmpeg分析视频流
  • 基于kettle实现pg数据定时转存mongodb
  • 使用 POI 在 Word 中重新开始编号、自定义标题格式
  • 【java】default/private/public/protected比较
  • 面试热题(最长上升子序列)
  • Vue 简版文件预览笔记