bholloway / resolve-url-loader

Webpack loader that resolves relative paths in url() statements based on the original source file
563 stars 71 forks source link

Failing to add prefix to urls. #35

Closed alexprice1 closed 7 years ago

alexprice1 commented 7 years ago

My local environment is setup to work like this:

localhost:8080

But my production environment looks like this:

https://domain.com/prefix.

I have gotten all my code to behave nicely with this, except for my images loaded from sass. So my css looks like this:

background-image: url(/images/logos/logo.svg);

When it should output like this:

background-image: url(/prefix/images/logos/logo.svg);

Any help is appreciated!

alexprice1 commented 7 years ago

For reference, I setup my publicPath within webpack, but that didn't work either.

bholloway commented 7 years ago

Can you please show your loader configuration for scss.

alexprice1 commented 7 years ago
      {
        test: /\.scss$/,
        loader: ExtractTextPlugin.extract(['css', 'sass'], {
          publicPath: '/root'
        }),
      },
ealves-pt commented 7 years ago

I have a similar problem. @alexprice91 did you find any solution for this?

Edit: Actually I've found the solution 10s after posting the question. Just defined in the webpack.config.json the following:

// ...
output: {
  // ...
  publicPath: '/some/nested/place/',
  // ...
}
// ...
bholloway commented 7 years ago

Try adding the sourceMap option to sass loader.

bholloway commented 7 years ago

@alexprice91 How are you going with this? Did you fix your problem?

bholloway commented 7 years ago

I'm going to close due to lack of activity. We can always reopen.

@alexprice91 please ask further questions here until you are happy. @ealves-pt sounds like you are already there but same goes for you otherwise.

Anyone else please open a new issue.