我正试图绕过broccoli.js,但遇到了错误。如果您查看我的GitHub仓库,您会看到我有一个看起来像这样的brocfile.js:
brocfile.js
var compileES6 = require('broccoli-es6-concatenator')
var pickFiles = require('broccoli-static-compiler');
var mergeTrees = require('broccoli-merge-trees')
var app = 'app'
app = pickFiles(app,{
srcDir: '/',
destDir: 'app-kit'
})
var appJS = compileES6(app, {
inputFiles: ['/app-kit/**/*.js'],
outputFile: '/dist/app.js'
})
module.exports = mergeTrees([appJS]);
我收到此错误:
Built with error:
Error: ENOENT, no such file or directory 'tmp/static_compiler-tmp_dest_dir-JjclDVEm.tmp/undefined'
at Object.fs.statSync (fs.js:684:18)
at addLegacyFile (/Users/cully/Sites/ember-todo/node_modules/broccoli-es6-concatenator/index.js:130:44)
at /Users/cully/Sites/ember-todo/node_modules/broccoli-es6-concatenator/index.js:47:5
at invokeCallback (/Users/cully/Sites/ember-todo/node_modules/broccoli/node_modules/rsvp/dist/commonjs/rsvp/promise.js:228:21)
at publish (/Users/cully/Sites/ember-todo/node_modules/broccoli/node_modules/rsvp/dist/commonjs/rsvp/promise.js:176:9)
at publishFulfillment (/Users/cully/Sites/ember-todo/node_modules/broccoli/node_modules/rsvp/dist/commonjs/rsvp/promise.js:312:5)
at flush (/Users/cully/Sites/ember-todo/node_modules/broccoli/node_modules/rsvp/dist/commonjs/rsvp/asap.js:41:9)
at process._tickCallback (node.js:415:13)
at Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
从长远来看,我想用这个作为构建ember.js应用程序的起点,所以我创建了一个github repo。如果你去那里你可以看到我的文件结构。有关为什么我收到此错误的任何想法?
答案 0 :(得分:4)
过去几天我一直在和Broccoli摔跤。这对我来说也是新的,但我克隆了你的回购并通过以下方式让broccoli serve
工作:
1)我在loader/loader.js
创建了一个“loader.js”文件。 loader.js文件包含ES6 Module Loader polyfill代码,允许ES6模块加载到非ES6浏览器中。我从Broccoli示例应用程序中抓取了该文件:https://github.com/joliss/broccoli-sample-app/blob/master/vendor/loader.js
2)我将加载程序注入到应用程序树中,并在compileES6
配置中引用它。 (此选项是错误中的undefined
值。)
以下是为我成功构建的更新brocfile.js
。
//brocfile.js
var compileES6 = require('broccoli-es6-concatenator');
var pickFiles = require('broccoli-static-compiler');
var mergeTrees = require('broccoli-merge-trees');
var app = 'app';
app = pickFiles(app,{
srcDir: '/',
destDir: 'app-kit'
});
// Reference to ES6 loader
var loader = "loader";
// Squash the loader and app trees into one
var sourceTrees = [app, loader];
sourceTrees = new mergeTrees(sourceTrees);
var appJS = compileES6(sourceTrees, {
loaderFile: 'loader.js', // This required option was undefined before
inputFiles: ['app-kit/**/*.js'],
outputFile: '/dist/app.js'
});
module.exports = mergeTrees([appJS]);
我希望这有助于您进入Broccoli冒险的下一步。
答案 1 :(得分:1)
您可以使用broccoli-concat,然后:
emberTests = concatFilter(emberTests, {inputFiles: ['**/*.js'], outputFile:'/tests.js'});
templates = concatFilter(templates, {inputFiles: ['**/*.handlebars'], outputFile:'/templates.js'});
trees = concatFilter(trees, {inputFiles: ['**/*.js'], outputFile:'/app.js'});