简体   繁体   English

在Ember CLI Project中使用Broccoli JS移动整个文件夹

[英]Move Entire Folder using Broccoli JS in Ember CLI Project

I am developing an ember-cli project and I am working on a system that allows me to resolve templates that have not been loaded and may possibly live outside of the project structure. 我正在开发一个ember-cli项目,我正在开发一个系统,它允许我解析未加载的模板,并且可能存在于项目结构之外。

I would like to have a folder in my dist/assets directory called templates and inside that folder would be all the pre compiled templates from app/templates/external . 我想在我的dist/assets目录中有一个名为templates文件夹,在该文件夹中将是app/templates/external所有预编译模板。 This is my current Brocfile.js attempt with broccoli stew 这是我目前的Brocfile.js尝试用西兰花炖

var EmberApp = require('ember-cli/lib/broccoli/ember-app');
var stew = require("broccoli-stew");

var app = new EmberApp({
  vendorFiles: {
    "jquery.js": null
  },
  sassOptions: {
      includePaths: [
        'bower_components/bourbon/app/assets/stylesheets/',
        'bower_components/neat/app/assets/stylesheets/',
        'bower_components/bitters/app/assets/stylesheets/'
      ]
    }
});

var additionalTrees = [];

var templateFiles = stew.find(appTree, "assets/app/templates/external");
templateFiles = stew.mv(templateFiles, "assets/app/templates/external", "assets/templates");
additionalTrees.push(templateFiles);

module.exports = app.toTree(additionalTrees);

There is npm package called broccoli-file-mover , easy to use , and can be found here 有一个名为broccoli-file-mover的 npm软件包,易于使用,可以在这里找到

The usage is very simple , as easy as : 用法非常简单,就像:

moveFile(inputTree, options) moveFile(inputTree,options)

can be used to move files ( multiple , or single ) , or whole folders 可用于移动文件(多个或单个)或整个文件夹

Example : 示例:

Moving a single file from app/main to app: 将单个文件从app / main移动到app:

var moveFile = require('broccoli-file-mover');

var tree = moveFile('app', {
  srcFile: 'app/main.js',
  destFile: '/app.js'
});

Moving app/main to app and test/main to test: 将app / main移动到app并测试/ main测试:

var moveFile = require('broccoli-file-mover');

var tree = moveFile('app', {
  files: {
    'app/main.js': 'app.js',
    'test/main.js': 'test.js'
  }
});

Also , prior to blessnm comment broccoli funnel is a possible solution , as you can copy your directory to wherever you want ( thought the question states moving , but thought copying might be an acceptable solution ) , here is the repo of the plugin. 此外 ,在blessnm评论之前,broccoli漏斗是一种可能的解决方案,因为您可以将目录复制到您想要的任何位置(认为问题表明移动,但认为复制可能是一个可接受的解决方案), 这里是插件的回购。

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

相关问题 Ember Cli不使用西兰花汇编汇编程序进行编译 - Ember Cli not compiling with broccoli-emblem-compiler 在Windows上安装Ember.js:无法加载应用程序:找不到模块'ember-cli / lib / broccoli / ember-app' - Ember.js install on Windows: Will not load app: Cannot find module 'ember-cli/lib/broccoli/ember-app' ember-cli-build.js | 根据环境设置西兰花的参数 - ember-cli-build.js | set broccoli's params depending on environmnet Broccoli.js和Ember-CLI:试图使SCSS编译器正常工作 - Broccoli.js and Ember-CLI : trying to get SCSS compiler to work 如何为特定的浏览器导入脚本Ember-CLi Broccoli - How to import scripts for specific browsers Ember-CLi Broccoli ember cli应用程序构建失败:Broccoli插件:[object Object]失败: - ember cli application build fails: The Broccoli Plugin: [object Object] failed with: Ember-cli构建错误-Broccoli插件:[broccoli-persistent-filter:TemplateCompiler]失败,原因是: - Ember-cli build error— The Broccoli Plugin: [broccoli-persistent-filter:TemplateCompiler] failed with: ember-cli-broccoli失败,出现EEXIST…tmp / .DS_STORE - ember-cli-broccoli fails with EEXIST … tmp/.DS_STORE 使用Ember CLI和broccoli-compass添加供应商CSS库 - Adding vendor CSS libraries with Ember CLI and broccoli-compass Ember js 构建错误 (broccoli-persistent-filter:EslintValidationFilter) - Ember js Build Error (broccoli-persistent-filter:EslintValidationFilter)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM