我的ember插件如何告诉主机应用程序包含特定的资产?



我有一个库,其中有一些静态资产——png、svg、woff——和一个Sass文件。库看起来像

- sass/
  - my-library/
    - all.scss
- images/
  - my-libarary/
    - logo.png

我想增强这个项目,使其与使用Ember -cli的Ember应用程序的工作。目标是让宿主应用程序以

结尾
- dist/
  - assets/
    - my-library/
      - all.css
      - logo.png

这是我尝试的:

treeFor: function(type) {
  if (type !== 'styles') { return; }
  var sass = require('broccoli-sass');
  var mergeTrees = require('broccoli-merge-trees');
  var funnel = require('broccoli-funnel');
  var asCss = sass(
    [ path.join(absolutePathToMyLibrary, 'sass') ],
    'my-library/all.scss',
    'my-library/all.css'
  ];
  // Hoping to compile sass/my-library/all.scss to assets/my-library/all.css
  var css = funnel(asCss, {
    files: [ 'my-library/all.scss' ],
    destDir: 'assets'
  });
  // Hoping to copy images/my-library/* to assets/my-library/*
  var images = funnel(path.join(absolutePathToMyLibrary, 'images'), {
    destDir: 'assets'
  });
  return mergeTrees(css, images);
}

但是我得到

ENOENT, no such file or directory '/Users/me/Code/my-app/tmp/tree_merger-tmp_dest_dir-0WdzK7Cd.tmp/my-library/'

当我运行ember build

答案很简单:我想要treeFor('public'),而不是treeFor('styles')。前者向构建中添加任意资产。后者是特定于app/styles的处理

相关内容

  • 没有找到相关文章