Where do I need to keep Image folder in ionic 2


#1

I kept image folder inside build folder. But after I do ionic serve the folder will be disappear. Help me


#2

The gulp tasks that are being run every time you rebuild your app will delete everything in the build folder. I think the default gulpfile should handle static assets somehow, but right now it doesn’t.

I store all images and other static assets in app/assets. I’ve modified my gulpfile.js so that it copies all files from app/assets to www/build/assets.

Here’s a sample gulpfile.js that does this:

https://gist.github.com/fuffenz/72845765c3bd8421345fb2bc1b7d9ba1

At least for beta7, you can just replace the default gulpfile.js with this one.


#3

In my app folder there is no assets folder. How I generate that??


#4

You can just create it as a regular folder.


#6

Cannot find module ‘ionic-gulp-browserify-es2015’ (I’m getting this error when I do ionic serve)


#7

I changed the gulpfile.js. but after I do ionic serve assets folder desappear from www/build/


#8

This is most probably because you have a TypeScript project and the sample gulpfile.js provided by @fuffenz is for a JavaScript project.

I would recommend you to copy the base gulpfile.js for TypeScript and then apply the required changes by yourself, i.e. update the watch and build tasks by adding the assets task and copy the assets task itself to the file (see the TODO comments below):

// ...
// TODO: Update this task by adding 'assets' as shown below:
gulp.task('watch', ['clean'], function(done){
  runSequence(
    ['sass', 'html', 'fonts', 'scripts', 'assets'],
//...
// TODO: Update this task by adding 'assets' as shown below:
gulp.task('build', ['clean'], function(done){
  runSequence(
    ['sass', 'html', 'fonts', 'scripts', 'assets'],
// ...
// TODO: Copy the task below to your gulpfile.js.
// copy "assets" folder and its content from /app/assets to /www/build/assets
gulp.task('assets', function() {
   return gulp.src('app/assets/*.*')
   .pipe(gulp.dest('www/build/assets'));
});
// ...

I would also recommend you to check out the following topic:


App destroy img folder
#9

thank u I fixed the issue…!! :slight_smile: