当使用requirejs优化器时,有可能在html文件中configuration内容吗?
我发现可以使用onBuildWrite获取js文件的内容,但是我需要一种方法将值注入到根html页面,这可能吗? EG,我们想换一个css版本的less文件。
这是可能的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');
只需将其添加为构build脚本的一部分,并调用r.js.
- 我们可以使用Electron开发桌面应用程序来监视远程Windows服务
- 当html5Mode为true时,AngularJs路由向服务器发起HTTP调用
- 通过Node.JS连接到RedisToGo
- 如何获得在MongoDB与mongoosefindAndModify func的返回值?
- 将轻量级Web服务器embedded到.net应用程序(node.js)中?
- 需要帮助消化使用express-handlebars node.js返回的JSON blob
- 哟meanjs错误 – 错误:命令失败:/ bin / sh -c cd test7 && npm install
- ejs代码显示由Sails中的PostController.js发送的stringvariables
- 以编程方式保存chrome的控制台日志