Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images in css files only visible after a re-save #15

Open
eivindml opened this issue Aug 30, 2019 · 0 comments
Open

Images in css files only visible after a re-save #15

eivindml opened this issue Aug 30, 2019 · 0 comments

Comments

@eivindml
Copy link

eivindml commented Aug 30, 2019

I have some background images defined in my css, like this:

background-image: url('/build/images/logo-mobile.png')

On my first run, images defined in css is not shown, and I get console.log errors for them, like " 404 http://localhost:8080/build/images/logo-desktop.png".

The run script is (hot reloading):

cross-env NODE_ENV=development webpack-dev-server --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js

But if I go into the css file that defines the image background url, and just change whatever, and save it, then everything is picked up by laravel mix, and all url's are correct. If I restart webpack-dev-server, then the image asset url's are not working again.

My full webpack.mix.js:

const mix = require('laravel-mix')
const autoprefixer = require('autoprefixer')

const autoprefixOptions = {}

const options = {
  postCss: [
    autoprefixer(autoprefixOptions)
  ]
}

const browserSync = {
  notify: false,
  files: [
    'templates/**/*'
  ]
}

mix
  .setPublicPath('web/build')
  .copy('assets/static/fonts/', 'web/build/fonts/')
  .copy('assets/static/images/', 'web/build/images/')
  .copy('assets/static/favico/', 'web/build/favico/')
  .js('assets/js/app.js', 'web/build/app.js')
  .sass('assets/sass/main.sass', 'web/build/app.css')
  .sourceMaps()
  .options(options)
  .browserSync(browserSync)

Any ideas what's going on?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant