Hello first off I am pretty new to broccoli and ember cli (node stuff) so my apologies in advance if I get a few things wrong. I would like to read an entire folder of files and merge the content into on file which I can import somewhere in the application. So I started to play around in the ember-cli build file which seems to be a logical place to start.
The files I want to export are simple objects, which is a problem as es6 does not allow to just have
{ test: 'hello', test2: 'oh' }
you always need some thing like
export default { test: 'hello', test2: 'no' }
besides that I thought I could use the broccoli-concat
plugin.
const mirage = concatFilter(
'mirage/scenarios',
{
inputFiles: ['test-*.js'],
outputFile: '/merged-files.js',
header: 'export default [',
footer: ']',
separator: ',',
},
'SimpleConcat'
)
And with that the end-result should look like something like this
export default [
{ test: 'world', test2: 'hello' },
{ test: 'world', test2: 'hello' }
]
which kind of does what I want it to do but it fails to create the merged file because its failing parsing the input files. So I have 2 problems to solve:
- how do make the concat plugin not parse the files (I cant see that there is an option in the source)
- How would I import such a file?
Other then that, does anyone maybe has a better idea how I can achieve such a thing.
Best regards Thomas