//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)})