首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >早午餐配置文件conventions.assets:如何从非默认位置复制?

早午餐配置文件conventions.assets:如何从非默认位置复制?
EN

Stack Overflow用户
提问于 2013-09-03 15:05:02
回答 2查看 1.2K关注 0票数 5

根据早午餐文档,配置文件中的属性"conventions.assets“应该是regexp,但我试图包括以下内容:

代码语言:javascript
复制
conventions: {
    assets: /^app\/.*\.html/
}

以便将所有html添加到公用文件夹中。(我知道我可以创建一个资产文件夹并包含所有的东西,但根据我们商定的结构,到目前为止还不可能)。

我认为这个属性需要一个目录,在这种情况下,我能修复这个值以达到我的目标吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-09-04 08:35:03

最后,我可以重写属性“资产”所接受的方法。

代码语言:javascript
复制
assets: function(path) {
    /**
     * Loops every path and returns path|true|false according what we need
     * @param   path    file or directory's path
     * @returns path    if it is a directory
     *          true    if it fit with the regular expression
     *          false   otherwise
     *
     */
    if( /\/$/.test(path) ) return path;
    return /^app\/.*\.html/.test(path); // RegExp for anything we need
}
票数 3
EN

Stack Overflow用户

发布于 2016-08-25 09:30:08

我只是想评论一下我的函数是什么样子的,如果有人很难弄明白如何继续:

代码语言:javascript
复制
assets: function(path) {
 /**
  * Loops every path and returns path|true|false according what we need
  * @param   path    file or directory's path
  * @returns path    if it is a directory
  *          true    if it fit with the regular expression
  *          false   otherwise
  *
  */
  if( /\/$/.test(path) ) return path;
  return /^(app|assets)\/.*\.(html|png|jpg|jpeg|eot|svg|ttf|woff)/.test(path);
}

这将将扩展名为:appassets-folder的文件移动到public-folder中。

我决定将assets-folder移到根结构,所以我们的结构现在如下所示:

代码语言:javascript
复制
frontend
  - app
  -- common/
  -- styles/
  -- etc etc
  - assets
  -- index.html
  -- css/
  -- images/
  -- etc etc
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18595609

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档