用postcss给less加上webkit前缀
//app3.js
//给less加上webkit前缀
const glob=require('glob');
const autoprefixer = require('autoprefixer')
const postcss = require('postcss')
const fs = require('fs')
const syntax = require('postcss-less');
const mkdir=require('./utils/mkdir');
const srcDir='./src/';
const lessFileArr=glob.sync(srcDir+'**/*.less');
//给less加上webkit前缀
lessFileArr.forEach(async function (lesspath) {
const lessText=fs.readFileSync(lesspath);
const result=await postcss([ autoprefixer({ overrideBrowserslist: ['last 2 versions']})])
.process(lessText, { syntax: syntax });
mkdir(lesspath.replace(srcDir,'./dist/'));
fs.writeFileSync(lesspath.replace(srcDir,'./dist/'),result.content)
})
const cssFileArr=glob.sync(srcDir+'**/*.css');
//给css加上webkit前缀
cssFileArr.forEach(async function (csspath) {
const cssText=fs.readFileSync(csspath);
const result=await postcss([ autoprefixer({ overrideBrowserslist: ['last 2 versions']})])
.process(cssText, { syntax: syntax });
mkdir(csspath.replace(srcDir,'./dist/'));
console.log(result.content)
fs.writeFileSync(csspath.replace(srcDir,'./dist/'),result.content)
})