2012-04-03 55 views

回答

1

很可能使用的是Node.js:

var fs = require('fs'); 
// read html file 
var fileContents = fs.readFileSync('index.html', 'utf8'); 
// replace rel attribute for less file with rel for css 
fileContents = fileContents.replace(/stylesheet\/less/gi, 'stylesheet'); 
// replace file name 
fileContents = fileContents.replace(/css\/application.less/gi, 'css/application.css'); 
// remove less runtime compiler (if needed) 
fileContents = fileContents.replace(/<script.*?\bless\b[^"']*?\.js.*?<\/script>/g, ''); 
// write file back 
fs.writeFileSync('index.html', fileContents, 'utf8'); 

只想補充一點,作爲構建腳本的一部分,與調用r.js.沿

相關問題