简体   繁体   English

如何在构建时更新Yeoman Angle中的HTML路径

[英]How to update html path in yeoman angular on build

I've just learning yeoman and grunt. 我刚刚学习yeoman和咕unt。 I have created a standard angular project using yeoman-angular generator. 我已经使用yeoman-angleular生成器创建了一个标准的角度项目。 I want my folder structures by features instead of by type. 我希望文件夹结构按功能而不是按类型。 for example, i have html in app/products/productlist.html and app/customers/customerlist.html. 例如,我在app / products / productlist.html和app / customers / customerlist.html中有html。 On build i want this html to be put to dist/templates folder. 在构建上,我希望将此html放入dist / templates文件夹。 How can i tell grunt to update the html refs accordingly. 我怎样才能告诉grunt相应地更新html refs。 Same with images. 与图像相同。 I put my images in app/assets/images, but on build i want to put it in dist/images folder. 我将图像放在app / assets / images中,但是在构建时,我想将其放在dist / images文件夹中。

You'll want to familiarize yourself with Node's core API. 您需要熟悉Node的核心API。

In your case get to know The File System Module . 就您而言,了解文件系统模块

Here's an example of how you could copy one file from one directory to another. 这是如何将一个文件从一个目录复制到另一个目录的示例。

var fs = require('fs'); //load file system module.
//create a writeable stream to your new file.
var out = fs.createWriteStream(path.join(__dirname, './B/file.js'));
//create a read stream from old file and pipe it to new file.
fs.createReadStream(path.join(__dirname, '/A/file.js')).pipe(out);

Voila, you're a pro! 瞧,你是专业人士! Now if you want to do something like grab all files ending in .html . 现在,如果您想做一些事情,例如抓取所有以.html结尾的文件。 You'll have to do stuff with fs.readdir . 您必须使用fs.readdir Now mind you fs.readdir is an asynchronous function so the scope of it will not be what you expect. 现在,请注意fs.readdir是一个asynchronous函数,因此它的范围将不是您期望的。 I'm sure you can fiind plenty of info on that topic though. 我相信您可以找到关于该主题的大量信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM