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

公众号文章排版厦门seo关键词排名

公众号文章排版,厦门seo关键词排名,软件开发工程师证书怎么考,网站制作验收单关于Vuewebpack使用unocss编写CSS,打包后CSS没加前缀,封装了一个插件去解决了这个问题 unocss-postcss-webpack-plugin unocss在vite中使用配置,关于unocss在vite中使用,自行查阅官网 https://unocss.dev/integrations/vite ,vi…

关于Vue+webpack使用unocss编写CSS,打包后CSS没加前缀,封装了一个插件去解决了这个问题

unocss-postcss-webpack-plugin

unocss在vite中使用配置,关于unocss在vite中使用,自行查阅官网 https://unocss.dev/integrations/vite ,vite使用unocss就不会出现这样的问题

//vite.config.ts
import { fileURLToPath, URL } from 'node:url'
import UnoCSS from 'unocss/vite'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'// https://vitejs.dev/config/
export default defineConfig({plugins: [vue(),vueJsx(),UnoCSS()],resolve: {alias: {'@': fileURLToPath(new URL('./src', import.meta.url))}},css: {postcss: {plugins: [require('autoprefixer')({overrideBrowserslist: ['Android >= 6', 'iOS >= 10', 'ie >= 11', 'Firefox >= 35', 'chrome >= 40','safari >= 6']})]},}
})

使用

<template><div><div class="w-200px h-200px bg-gray-400 flex items-center justify-center">vite中使用unocss的写法</div><div class="box">vite中没有使用unocss的写法</div></div>
</template><script setup lang="ts"></script><style scoped>
.box{display: flex;align-items: center;justify-content: center;background-color: red;width: 200px;height: 200px;
}
</style>

CSS展示

1
2

unocss在webpack中使用配置,关于unocss在webpack中使用,自行查阅官网 https://unocss.dev/integrations/webpack

const { defineConfig } = require('@vue/cli-service');
const UnoCSS = require('@unocss/webpack').default
module.exports = defineConfig({lintOnSave: false,transpileDependencies: true,configureWebpack: {plugins: [UnoCSS({})],},css: {loaderOptions: {postcss: {postcssOptions: {plugins: [require('autoprefixer')({overrideBrowserslist: ['Android >= 6', 'iOS >= 10', 'ie >= 11', 'Firefox >= 35', 'chrome >= 40','safari >= 6']})],},},}},
});
<template><div><div class="w-200px h-200px bg-gray-400 flex items-center justify-center">webpack使用unocss的写法</div><div class="box">webpack没有使用unocss的写法</div></div>
</template><script setup lang="ts"></script><style scoped>
.box{display: flex;align-items: center;justify-content: center;background-color: red;width: 200px;height: 200px;
}
</style>

CSS展示

1
2

比较发现,在webpack中,unocss写法的css样式没有添加css前缀,详情可看这个issue https://github.com/unocss/unocss/issues/386

使用unocss-postcss-webpack-plugin插件 webpack中,unocss 添加 postcss 编译 ,配合@unocss/webpack使用,前提已在项目中配置了unocss相关配置,以及项目中的css是单独打包成独立的css文件

install

npm i unocss-postcss-webpack-plugin -D

使用

//vue.config.js
const { defineConfig } = require('@vue/cli-service');
const UnoCSS = require('@unocss/webpack').default
const unocssPostcssWebpackPlugin=require('unocss-postcss-webpack-plugin')
module.exports = {configureWebpack: {plugins: [UnoCSS({}),unocssPostcssWebpackPlugin(), ],},css:{loaderOptions: {postcss: {postcssOptions: {plugins: [require('autoprefixer')({overrideBrowserslist: ['Android >= 6', 'iOS >= 10', 'ie >= 11', 'Firefox >= 35', 'chrome >= 40','safari >= 6']})],},},},extract:true,//这个主要是设置单独打包css,}
}

CSS展示

unocss编写的css样式也加上了css前缀

3

props

PropTypeDefaultdescriptionrequired
overrideBrowserslistArray[‘Android >= 6’, ‘iOS >= 10’, 'ie >= 1,‘Firefox >= 35’, ‘chrome >= 40’,‘safari >= 6’]browserslistfalse
http://www.hyszgw.com/news/5406.html

相关文章:

  • 织梦网站开通在线投稿整站多关键词优化
  • 用废旧盒子做家用物品网站建站系统cms
  • 新网 网站备案建一个网站需要多少钱?
  • 做网站参考线怎么拉互联网营销师是做什么的
  • 上海如何做网站长沙网站推广公司排名
  • 网站接入商查询网站模板价格
  • 想学做网站从哪里入手营销方案
  • wordpress侧栏推荐文章苏州seo推广
  • 汽车服务网站建设方案北京网站外包
  • ASP动态网站开发案例教程seo网站推广助理
  • 网站开发是编程吗重庆快速网络推广
  • 0592 网站建设关键词优化多少钱
  • 国外皇色网站深圳龙岗区布吉街道
  • 淄博网站建设 百度知道温州网站建设制作
  • 如何做网站流量买卖淘宝如何刷关键词增加权重
  • 周口网站设计10条重大新闻
  • 深圳建设网站推荐企业网站怎么做
  • 百度怎么做网站广告济南网站建设
  • 西安城乡建设委员会网站打不开搜索引擎优化工作
  • 建设一个外贸网站需要多少钱如何销售自己产品方法有哪些
  • 网站开发的工具dy刷粉网站推广马上刷
  • 织梦网站怎样做子域名武汉百度
  • 做内容网站 用什么模版360投放广告怎么收费
  • 学校网站建设目的优化快速排名公司
  • 房产网站流量排名外贸展示型网站建设公司
  • 做网站鼠标移动 链接变颜色咸宁网站seo
  • 妹妹强迫我和她做网站美发培训职业学校
  • 长春企业网站如何建设如何进行网络推广营销
  • 适合新手做的网站2024年新闻时事热点论文
  • 美团网站建设规划书东莞网络推广招聘