准备

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

package.json

"devDependencies": {
"autoprefixer": "^7.1.1",
"browser-sync": "^2.18.8",
"compass": "^0.1.1",
"gulp": "^3.9.1",
"gulp-changed": "^2.0.0",
"gulp-compass": "^2.1.0",
"gulp-html-beautify": "^1.0.1",
"gulp-load-plugins": "^1.5.0",
"gulp-plumber": "^1.1.0",
"gulp-postcss": "^7.0.0",
"gulp-pug": "^3.3.0",
"gulp-sass": "^3.1.0",
"gulp-sourcemaps": "^2.6.0",
"precss": "^1.4.0",
"pug": "^2.0.0-beta.12",
"cssgrace": "^3.0.0"
},
"dependencies": {
"express": "^4.15.2",
"pug": "^2.0.0-beta.12"
}

  

gulpfile.js

var gulp        = require("gulp");
var plugins = require("gulp-load-plugins")();
var browserSync = require("browser-sync").create();
var postcss = require('gulp-postcss');
var sourcemaps = require('gulp-sourcemaps');
var cssgrace = require('cssgrace');
// /*执行命令行工具*/
// var exec = require('child_process').exec;
// exec("node server/index.js", function(err, stdout, stderr) {
// var status = err ? -1 : 1,
// cmd_result = err ? stderr : stdout;
// // 可以获取到错误信息、标准输出和标准错误输出,接下来继续处理吧
// }); //编译pug
gulp.task("pug:compile",function() {
gulp.src("src/*.pug")
.pipe(plugins.plumber())
.pipe(plugins.changed("./build/",{extension:".html"}))
.pipe(plugins.pug({
pretty:"\t"
}))
.pipe(plugins.htmlBeautify({
indent_size:4,
indent_char:" "
}))
.pipe(gulp.dest("./build/"))
})
//监控pug
gulp.task("pug:watch",function() {
gulp.watch("src/*.pug",["pug:compile"])
})
//编译pug-templates
gulp.task('pug-templates:compile',function(){
gulp.src('src/*.pug')
.pipe(plugins.plumber())
.pipe(plugins.pug({
pretty: '\t'
}))
.pipe(plugins.htmlBeautify({
indent_size: 4,
indent_char: ' ',
unformatted: true,
extra_liners: []
}))
.pipe(gulp.dest('./build/'));
});
//监控pug-templates
gulp.task('pug-templates:watch',function(){
gulp.watch('src/templates/*.pug',['pug-templates:compile']);
}); /*编译compass*/
gulp.task("compass:compile",function() {
gulp.src("src/sass/sass_parts/*.scss")
.pipe(plugins.plumber())
.pipe(plugins.compass({
config_file:"./src/sass/config.rb",
sass:"src/sass/sass_parts",
css:"src/sass/stylesheets"
}))
.pipe(sourcemaps.init())
.pipe( postcss([ require('precss'), require('autoprefixer'), cssgrace ]) )
.pipe( sourcemaps.write('.') )
.pipe(gulp.dest("./build/css"));
})
//监控compass sass
gulp.task("compass:watch",function() {
gulp.watch("src/sass/sass_parts/**/*.scss",["compass:compile"]);
});
//browser-sync
gulp.task("browser-sync",function() {
var files = [
"./build/*.html",
"./build/**/*.css",
"./build/**/*.js"
];
browserSync.init(files,{
server:{
baseDir:"./build"
},
port:3061
})
})
gulp.task("default",["pug:watch","pug-templates:watch","compass:watch","browser-sync"])

 

src结构目录

 

postcss使用的更多相关文章

  1. 展望未来:使用 PostCSS 和 cssnext 书写 CSS

    原文链接:A look into writing future CSS with PostCSS and cssnext 译者:nzbin 像twitter,google,bbc使用的一样,我打算看一 ...

  2. PostCSS深入学习: PostCSS和Sass、Stylus或LESS一起使用

    如果你喜欢使用PostCSS,但又不想抛弃你最喜欢的预处理器.不用担心,你不需要作出二选一的选择,你可以把PostCSS和预处理器(Sass.Stylus或LESS)结合起来使用. 有几个PostCS ...

  3. 在 CSS 预编译器之后:PostCSS

    提到css预编译器(css preprocessor),你可能想到Sass.Less以及Stylus.而本文要介绍的PostCSS,正是一个这样的工具:css预编译器可以做到的事,它同样可以做到. “ ...

  4. PostCSS一种更优雅、更简单的书写CSS方式

    Sass团队创建了Compass大大提升CSSer的工作效率,你无需考虑各种浏览器前缀兼,只需要按官方文档的书写方式去写,会得到加上浏览器前缀的代码,如下: .row { @include displ ...

  5. [译]PostCSS介绍

    PostCSS介绍 原文链接:http://www.smashingmagazine.com/2015/12/introduction-to-postcss/ 转自:http://www.zcfy.c ...

  6. PostCss 从0开始

    PostCss 摘自 http://ju.outofmemory.cn/entry/215105 http://www.w3cplus.com/PostCSS/postcss-deep-dive-pr ...

  7. CSS预编译与PostCSS以及Webpack构建CSS综合方案

    CSS全称Cascading Style Sheets(层叠样式表),用来为HTML添加样式,本质上是一种标记类语言.CSS前期发展非常迅速,1994年哈肯·维姆·莱首次提出CSS,1996年12月W ...

  8. 更便捷的css处理方式-postcss

    更便捷的css处理方式-PostCSS 一般来说介绍一个东西都是要从是什么,怎么用的顺序来讲.我感觉这样很容易让大家失去兴趣,先看一下postcss能做点什么,有兴趣的话再往下看,否则可能没有耐心看下 ...

  9. postcss的安装与使用

    我是经过公司另外一个同事推荐的这个 他是一个资深的大哥哥  我觉得我确实需要跟多的学习和成长 而且我觉得我应该听他的话 多学学新知识 最近一直在做适配的网站 会出现很多媒体查询 我发现用这个写媒体查询 ...

随机推荐

  1. vue视频学习笔记02

    video 2 vue制作weibo交互 vue-> 1.0vue-resource ajax php服务器环境(node) this.$http.get()/post()/jsonp() th ...

  2. LinkedHashMap:我还能实现LRU

    众所周知,LinkedHashMap继承自HashMap,在原先的HashMap的基础上,它增加了Entry的双向链接. 有意思的是基于这种实现特性,LinkedHashMap 在迭代遍历时,取得键值 ...

  3. 面试(1)-java-se-字符串

    http://blog.csdn.net/zhangerqing/article/details/8093919 hashCode和identityHashCode的区别 I. hashCode()方 ...

  4. 开涛spring3(6.3) - AOP 之 6.3 基于Schema的AOP

    6.3  基于Schema的AOP 基于Schema的AOP从Spring2.0之后通过“aop”命名空间来定义切面.切入点及声明通知. 在Spring配置文件中,所以AOP相关定义必须放在<a ...

  5. CoreCLR源码探索(六) NullReferenceException是如何发生的

    NullReferenceException可能是.Net程序员遇到最多的例外了, 这个例外发生的如此频繁, 以至于人们付出了巨大的努力来使用各种特性和约束试图防止它发生, 但时至今日它仍然让很多程序 ...

  6. Cohort Analysis and LifeCycle Grids mixed segmentation with R(转)

    This is the third post about LifeCycle Grids. You can find the first post about the sense of LifeCyc ...

  7. Spring与Mybatis整合

    一 概述 1.整合的目的 将Mapper映射器的创建任务交给Spring容器. 二 具体实现 1.创建sqlSessionFactory: <bean id="sqlSessionFa ...

  8. python-冒泡排序与插入排序

    def bubble_sort(L): """ 设计思路:从前往后遍历列表,每次选取列表中两个数进行比较,如果不符合排序的规则,则进行交换 这样一次遍历后,最大(最小)的 ...

  9. python str的一些方法

    在python有各种各样的string操作函数.在历史上string类在python中经历了一段轮回的历史.在最开始的时候,python有一个专门的string的module,要使用string的方法 ...

  10. Caffe代码分析--crop_layer.cu

    因为要修改Caffe crop layer GPU部分的代码,现将自己对这部分GPU代码的理解总结一下,请大家多多指教! crop layer完成的功能(以matlab的方式表示):A(N,C,H,W ...