简体   繁体   中英

trees:{ mergetrees(['src',external js file])} in ember-cli-build.js is not working

In glimmer application, I want to bundle the external Js file with app.js file. I want to use svg in glimmer application. Instead of ember-inline-svg,I used broccoli-flatiron and broccoli-merge-trees packages to bundle external js file with app.js.

My code in ember-cli-build.js is

const GlimmerApp      = require('@glimmer/application-pipeline').GlimmerApp;
const merge           = require('merge');
const fs              = require('fs');
const Funnel          = require('broccoli-funnel');
const flatiron        = require('broccoli-flatiron');
const mergeTree       = require('broccoli-merge-trees');

module.exports = function(defaults) {
 var options=merge(true, {}, {
   paths:   ['src/ui/styles/svgs']
 });

 var svgs = mergeTree(options.paths.filter(function(path) {
   return fs.existsSync(path);
 }));

 svgs = new Funnel(svgs, {
   include: [new RegExp(/\.svg$/)]
 });

 svgs = flatiron(svgs, {
   outputFile: 'svgs.js',
   trimExtensions: true,
   variableName : "const svgs = "
 });

 let app = new GlimmerApp(defaults, {

   trees:{
     src:mergeTree(['src',svgs])
   }


   });

 return app.toTree();

};

But it gives an error "The type of module 'svgs' could not be identified"...

I want to bundle svgs with app.js.

Try to merge the trees like this instead:

…

module.exports = function(defaults) {
  …

  let app = new GlimmerApp(defaults, { 
  });

  return mergeTree([app.toTree(), svgs]);
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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