Move Entire Folder using Broccoli JS in Ember CLI Project

685 views Asked by At

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.

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. This is my current Brocfile.js attempt with broccoli stew

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);
1

There are 1 answers

0
ProllyGeek On BEST ANSWER

There is npm package called broccoli-file-mover , easy to use , and can be found here

The usage is very simple , as easy as :

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:

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:

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.