images don't render in browser









up vote
1
down vote

favorite












I use gulp as a automation and build system and when I build websites when i have background image in my css file added as a background-image property when I run gulp everything render properly in the browser, when I try to open index.html with gulp off images which comes from css files aren't rendered only those ones which are embedded with img tag in my html file works fine it happens even with build version of my website.



my gulpfile.js



var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var cleanCSS = require('gulp-clean-css');
var uglify = require('gulp-uglify');
var imagemin = require('gulp-imagemin');
var changed = require('gulp-changed');
var htmlReplace = require('gulp-html-replace');
var htmlMin = require('gulp-htmlmin');
var del = require('del');
var sequence = require('run-sequence');


// Server
gulp.task('serve', ['sass'], function()
browserSync.init(
server: 'src'
);

gulp.watch("src/*.html").on('change', browserSync.reload);
gulp.watch('src/sass/**/*.scss', ['sass']);
);

// Compile SASS to CSS
gulp.task('sass', function()
return gulp.src('src/sass/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer(
browsers: ['last 3 versions']
))
.pipe(gulp.dest('src/css'))
.pipe(browserSync.stream());
);

gulp.task('css', function()
return gulp.src('src/css/**/*.css')
.pipe(cleanCSS())
.pipe(gulp.dest('dist/css'));

);

gulp.task('js', function()
return gulp.src('src/js/**/*.js')
.pipe(uglify())
.pipe(gulp.dest('dist/js'));

);

gulp.task('img', function()
return gulp.src('src/img/**/*.jpg,jpeg,png,gif')
.pipe(changed('dist/img'))
.pipe(imagemin())
.pipe(gulp.dest('dist/img'));

);

gulp.task('html', function()
return gulp.src('src/*.html')
.pipe(htmlReplace(
'css': 'css/main.css',
'js': 'js/script.js'
))
.pipe(htmlMin(
sortAttributes: true,
sortClassName: true
))
.pipe(gulp.dest('dist/'));
);

gulp.task('clean', function()
return del(['dist'])
);

gulp.task('build', function()
sequence('clean', ['html', 'js', 'css', 'img']);
);

gulp.task('default', ['serve']);


package.json



"devDependencies": 
"browser-sync": "^2.26.0",
"del": "^3.0.0",
"eslint": "^5.6.1",
"gulp": "^3.9.1",
"gulp-autoprefixer": "^6.0.0",
"gulp-changed": "^3.2.0",
"gulp-clean-css": "^3.10.0",
"gulp-html-replace": "^1.6.2",
"gulp-htmlmin": "^5.0.1",
"gulp-imagemin": "^4.1.0",
"gulp-sass": "^4.0.1",
"gulp-uglify": "^3.0.1",
"node-sass": "^4.9.3",
"run-sequence": "^2.2.1"










share|improve this question

























    up vote
    1
    down vote

    favorite












    I use gulp as a automation and build system and when I build websites when i have background image in my css file added as a background-image property when I run gulp everything render properly in the browser, when I try to open index.html with gulp off images which comes from css files aren't rendered only those ones which are embedded with img tag in my html file works fine it happens even with build version of my website.



    my gulpfile.js



    var gulp = require('gulp');
    var browserSync = require('browser-sync').create();
    var sass = require('gulp-sass');
    var autoprefixer = require('gulp-autoprefixer');
    var cleanCSS = require('gulp-clean-css');
    var uglify = require('gulp-uglify');
    var imagemin = require('gulp-imagemin');
    var changed = require('gulp-changed');
    var htmlReplace = require('gulp-html-replace');
    var htmlMin = require('gulp-htmlmin');
    var del = require('del');
    var sequence = require('run-sequence');


    // Server
    gulp.task('serve', ['sass'], function()
    browserSync.init(
    server: 'src'
    );

    gulp.watch("src/*.html").on('change', browserSync.reload);
    gulp.watch('src/sass/**/*.scss', ['sass']);
    );

    // Compile SASS to CSS
    gulp.task('sass', function()
    return gulp.src('src/sass/**/*.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(autoprefixer(
    browsers: ['last 3 versions']
    ))
    .pipe(gulp.dest('src/css'))
    .pipe(browserSync.stream());
    );

    gulp.task('css', function()
    return gulp.src('src/css/**/*.css')
    .pipe(cleanCSS())
    .pipe(gulp.dest('dist/css'));

    );

    gulp.task('js', function()
    return gulp.src('src/js/**/*.js')
    .pipe(uglify())
    .pipe(gulp.dest('dist/js'));

    );

    gulp.task('img', function()
    return gulp.src('src/img/**/*.jpg,jpeg,png,gif')
    .pipe(changed('dist/img'))
    .pipe(imagemin())
    .pipe(gulp.dest('dist/img'));

    );

    gulp.task('html', function()
    return gulp.src('src/*.html')
    .pipe(htmlReplace(
    'css': 'css/main.css',
    'js': 'js/script.js'
    ))
    .pipe(htmlMin(
    sortAttributes: true,
    sortClassName: true
    ))
    .pipe(gulp.dest('dist/'));
    );

    gulp.task('clean', function()
    return del(['dist'])
    );

    gulp.task('build', function()
    sequence('clean', ['html', 'js', 'css', 'img']);
    );

    gulp.task('default', ['serve']);


    package.json



    "devDependencies": 
    "browser-sync": "^2.26.0",
    "del": "^3.0.0",
    "eslint": "^5.6.1",
    "gulp": "^3.9.1",
    "gulp-autoprefixer": "^6.0.0",
    "gulp-changed": "^3.2.0",
    "gulp-clean-css": "^3.10.0",
    "gulp-html-replace": "^1.6.2",
    "gulp-htmlmin": "^5.0.1",
    "gulp-imagemin": "^4.1.0",
    "gulp-sass": "^4.0.1",
    "gulp-uglify": "^3.0.1",
    "node-sass": "^4.9.3",
    "run-sequence": "^2.2.1"










    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I use gulp as a automation and build system and when I build websites when i have background image in my css file added as a background-image property when I run gulp everything render properly in the browser, when I try to open index.html with gulp off images which comes from css files aren't rendered only those ones which are embedded with img tag in my html file works fine it happens even with build version of my website.



      my gulpfile.js



      var gulp = require('gulp');
      var browserSync = require('browser-sync').create();
      var sass = require('gulp-sass');
      var autoprefixer = require('gulp-autoprefixer');
      var cleanCSS = require('gulp-clean-css');
      var uglify = require('gulp-uglify');
      var imagemin = require('gulp-imagemin');
      var changed = require('gulp-changed');
      var htmlReplace = require('gulp-html-replace');
      var htmlMin = require('gulp-htmlmin');
      var del = require('del');
      var sequence = require('run-sequence');


      // Server
      gulp.task('serve', ['sass'], function()
      browserSync.init(
      server: 'src'
      );

      gulp.watch("src/*.html").on('change', browserSync.reload);
      gulp.watch('src/sass/**/*.scss', ['sass']);
      );

      // Compile SASS to CSS
      gulp.task('sass', function()
      return gulp.src('src/sass/**/*.scss')
      .pipe(sass().on('error', sass.logError))
      .pipe(autoprefixer(
      browsers: ['last 3 versions']
      ))
      .pipe(gulp.dest('src/css'))
      .pipe(browserSync.stream());
      );

      gulp.task('css', function()
      return gulp.src('src/css/**/*.css')
      .pipe(cleanCSS())
      .pipe(gulp.dest('dist/css'));

      );

      gulp.task('js', function()
      return gulp.src('src/js/**/*.js')
      .pipe(uglify())
      .pipe(gulp.dest('dist/js'));

      );

      gulp.task('img', function()
      return gulp.src('src/img/**/*.jpg,jpeg,png,gif')
      .pipe(changed('dist/img'))
      .pipe(imagemin())
      .pipe(gulp.dest('dist/img'));

      );

      gulp.task('html', function()
      return gulp.src('src/*.html')
      .pipe(htmlReplace(
      'css': 'css/main.css',
      'js': 'js/script.js'
      ))
      .pipe(htmlMin(
      sortAttributes: true,
      sortClassName: true
      ))
      .pipe(gulp.dest('dist/'));
      );

      gulp.task('clean', function()
      return del(['dist'])
      );

      gulp.task('build', function()
      sequence('clean', ['html', 'js', 'css', 'img']);
      );

      gulp.task('default', ['serve']);


      package.json



      "devDependencies": 
      "browser-sync": "^2.26.0",
      "del": "^3.0.0",
      "eslint": "^5.6.1",
      "gulp": "^3.9.1",
      "gulp-autoprefixer": "^6.0.0",
      "gulp-changed": "^3.2.0",
      "gulp-clean-css": "^3.10.0",
      "gulp-html-replace": "^1.6.2",
      "gulp-htmlmin": "^5.0.1",
      "gulp-imagemin": "^4.1.0",
      "gulp-sass": "^4.0.1",
      "gulp-uglify": "^3.0.1",
      "node-sass": "^4.9.3",
      "run-sequence": "^2.2.1"










      share|improve this question













      I use gulp as a automation and build system and when I build websites when i have background image in my css file added as a background-image property when I run gulp everything render properly in the browser, when I try to open index.html with gulp off images which comes from css files aren't rendered only those ones which are embedded with img tag in my html file works fine it happens even with build version of my website.



      my gulpfile.js



      var gulp = require('gulp');
      var browserSync = require('browser-sync').create();
      var sass = require('gulp-sass');
      var autoprefixer = require('gulp-autoprefixer');
      var cleanCSS = require('gulp-clean-css');
      var uglify = require('gulp-uglify');
      var imagemin = require('gulp-imagemin');
      var changed = require('gulp-changed');
      var htmlReplace = require('gulp-html-replace');
      var htmlMin = require('gulp-htmlmin');
      var del = require('del');
      var sequence = require('run-sequence');


      // Server
      gulp.task('serve', ['sass'], function()
      browserSync.init(
      server: 'src'
      );

      gulp.watch("src/*.html").on('change', browserSync.reload);
      gulp.watch('src/sass/**/*.scss', ['sass']);
      );

      // Compile SASS to CSS
      gulp.task('sass', function()
      return gulp.src('src/sass/**/*.scss')
      .pipe(sass().on('error', sass.logError))
      .pipe(autoprefixer(
      browsers: ['last 3 versions']
      ))
      .pipe(gulp.dest('src/css'))
      .pipe(browserSync.stream());
      );

      gulp.task('css', function()
      return gulp.src('src/css/**/*.css')
      .pipe(cleanCSS())
      .pipe(gulp.dest('dist/css'));

      );

      gulp.task('js', function()
      return gulp.src('src/js/**/*.js')
      .pipe(uglify())
      .pipe(gulp.dest('dist/js'));

      );

      gulp.task('img', function()
      return gulp.src('src/img/**/*.jpg,jpeg,png,gif')
      .pipe(changed('dist/img'))
      .pipe(imagemin())
      .pipe(gulp.dest('dist/img'));

      );

      gulp.task('html', function()
      return gulp.src('src/*.html')
      .pipe(htmlReplace(
      'css': 'css/main.css',
      'js': 'js/script.js'
      ))
      .pipe(htmlMin(
      sortAttributes: true,
      sortClassName: true
      ))
      .pipe(gulp.dest('dist/'));
      );

      gulp.task('clean', function()
      return del(['dist'])
      );

      gulp.task('build', function()
      sequence('clean', ['html', 'js', 'css', 'img']);
      );

      gulp.task('default', ['serve']);


      package.json



      "devDependencies": 
      "browser-sync": "^2.26.0",
      "del": "^3.0.0",
      "eslint": "^5.6.1",
      "gulp": "^3.9.1",
      "gulp-autoprefixer": "^6.0.0",
      "gulp-changed": "^3.2.0",
      "gulp-clean-css": "^3.10.0",
      "gulp-html-replace": "^1.6.2",
      "gulp-htmlmin": "^5.0.1",
      "gulp-imagemin": "^4.1.0",
      "gulp-sass": "^4.0.1",
      "gulp-uglify": "^3.0.1",
      "node-sass": "^4.9.3",
      "run-sequence": "^2.2.1"







      html css gulp gulp-sass






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 10 at 15:36









      kam773

      216




      216



























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240493%2fimages-dont-render-in-browser%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240493%2fimages-dont-render-in-browser%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Top Tejano songwriter Luis Silva dead of heart attack at 64

          ReactJS Fetched API data displays live - need Data displayed static

          政党