侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

PostCSS - 优雅的后处理器

2024-05-10 星期五 / 0 评论 / 0 点赞 / 90 阅读 / 1708 字

构建工具为Gulp 基于PostCSS PostCSS插件CSSNext用下一代CSS书写方式兼容现在浏览器 PostCSS插件Autoprefixer为CSS补全浏览器前缀 PostCSS插件CSS

构建工具为 Gulp

基于 PostCSS

PostCSS插件 CSSNext 用下一代CSS书写方式兼容现在浏览器

PostCSS插件 Autoprefixer 为CSS补全浏览器前缀

PostCSS插件 CSS Grace 让CSS兼容旧版IE

package.json

{  "name": "postcss usage",  "version": "1.0.0",  "description": "postcss cssnext",  "main": "gulpfile.js",  "dependencies": {    "autoprefixer": "^5.2.0",    "autoprefixer-core": "^5.2.1",    "cssgrace": "^2.0.2",    "gulp": "^3.9.0",    "gulp-less": "^3.0.3"  },  "devDependencies": {    "autoprefixer": "^5.2.0",    "autoprefixer-core": "^5.2.1",    "cssgrace": "^2.0.2",    "cssnext": "^1.8.4",    "gulp-postcss": "^6.0.0",    "postcss": "^4.1.16"  },  "scripts": {    "test": "echo /"Error: no test specified/" && exit 1"  },  "keywords": [    "postcss",    "gulp"  ],  "author": "givebest",  "license": "ISC"}

gulpfile.js

var gulp = require('gulp');var postcss = require('gulp-postcss');var autoprefixer = require('autoprefixer');var cssgrace  = require('cssgrace');var cssnext  = require('cssnext');gulp.task('css', function () {  var processors = [    autoprefixer({browsers: ['last 3 version'],      cascade: false,      remove: false    }),    cssnext(),    cssgrace  ];  return gulp.src('./src/css/*.css')    .pipe(postcss(processors))    .pipe(gulp.dest('./dist'));});gulp.task('watch', function(){  gulp.watch('./src/css/*.css', ['css']);});gulp.task('default', ['watch', 'css']);

安装

npm install

使用

gulp

广告 广告

评论区