Reputation: 1407
I use the following code for babel transpile of code. My app is built like following
-src
-- bin
---www
-- routes
---index1.js
---index2.js
-- config.json
-package.json
Now I want that all this file will be transpiled to the dist folder
I use the following gulp
gulp.task('es6', () => {
return gulp.src(['src/**/*.js','./src/**/www','./src/**/*.json'])
.pipe(babel({
presets: ['es2015']
}))
.pipe(gulp.dest('dist'));
});
This create new dist of dist like following but without the config.json file,why ?
-dist
-- bin
---www
-- routes
---index1.js
---index2.js
and when I run the gulp file I got error
Cannot find module '../config.json'
,any idea how to solve it ?
I struggle with it almost 3 days, I think I miss something basic here...:( This is the project example ,you can do npm install and run gulp to see the error...
https://drive.google.com/open?id=0B8fd7J9aXGXaQng1ZFJkU2Z4OUk
Upvotes: 1
Views: 664
Reputation: 303
Download and it seems only an issue with babel-gulp which doesn't recognize the .json
edited like this and it works
gulp.task('es6', () => {
return gulp.src(['./src/**/*.js','./src/**/www'])
.pipe(babel({
presets: ['es2015']
}))
.pipe(gulp.dest('dist'));
});
gulp.task('json', () => {
return gulp.src(['./src/*.json'])
.pipe(gulp.dest('dist'))
})
and then
gulp.task('default', [ 'es6', 'json', 'nodemon'], () => {
console.log("Done");
});
Upvotes: 2
Reputation: 303
'./src/**/*.json'
but your config file is a direct child of src, so you should do:
'./src/*.json'
Upvotes: 0