Skip to content

Commit 2b0bb14

Browse files
author
liujia
committed
增加autoprefixer的浏览器选择入口
1 parent 9034dc4 commit 2b0bb14

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

lib/buildCss.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ buildCss.handleCss = function (vfile) {
111111
buildCss.postCSSProcess = function (vfile) {
112112
// 更多插件可以再扩展
113113
let cssAutoPrefixer = jdf.config.output.cssAutoPrefixer;
114-
let plugins = [autoprefixer({remove: cssAutoPrefixer})];
114+
let browsers = jdf.config.output.browserslist || [];
115+
let plugins = [autoprefixer({remove: cssAutoPrefixer, browsers: browsers})];
115116
logger.verbose(`postcss - autoprefixer: parsed ${vfile.originPath}`);
116117
return new Promise(function (resolve, reject) {
117118
postcss(plugins)

lib/config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ module.exports = {
5555
"rootPrefix": "/var/www/html/" // scp时传输的目录前缀,用来确认上传文件最终的地址,一个文件最终的地址会是rootPrefix + serverDir + projectPath + filePath,你可以根据自身server的配置来修改这个值
5656
},
5757
"output":{
58-
"linkReplace": true, // 给link.href添加cdn前缀,它和cssImagesUrlReplace相互独立
58+
"linkReplace": true, // 给link.href添加cdn前缀,它和cssImagesUrlReplace相互独立
5959
"cssImagesUrlReplace": true,//css中图片url加cdn替换
6060
"jsUrlReplace": true, //js文件的id和dependences是否添加cdn前缀,添加script.src cdn前缀
6161
"comboItemCount":2, //在同一个文件夹中,如果 js 或 css 文件数多于此数字,则会 combo
@@ -73,6 +73,7 @@ module.exports = {
7373
"cssSpriteMargin": 10, //css sprite图片之间的间距
7474
"cssSpriteDirection": 'vertical', //vertical:垂直合并,horizontal:水平合并
7575
"cssAutoPrefixer": true, //是否自动删除过时的浏览器css前缀
76+
"browserslist": ['last 2 version', '> 0.2%', 'ie > 7'], // autoprefixer的浏览器筛选
7677

7778
"base64": true, //是否对图片进行base64编码
7879
"webp":false, //是否生成对应的webp图片
@@ -90,7 +91,7 @@ module.exports = {
9091

9192
// 插件 "jdf-cms"
9293
"plugins": [],
93-
94+
9495
//依赖的组件列表
9596
"components": {}
9697
}

lib/pluginCore/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ core.require = function (pluginObj) {
6565
process.exit(-1);
6666
}
6767
}
68-
68+
6969
try {
7070
plugin = plugin.Plugin();
7171
} catch (e) {
7272
logger.error(`插件${moduleName}没有Plugin方法,请检查该插件是否合法`);
7373
console.log(e);
7474
process.exit(-1);
7575
}
76-
76+
7777
plugin.setConfig({
7878
VFS: VFS,
7979
jdf: jdf,

0 commit comments

Comments
 (0)