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

Question: bug with style-loader? #375

Closed
Bogdaan opened this issue Dec 29, 2015 · 10 comments · Fixed by #920
Closed

Question: bug with style-loader? #375

Bogdaan opened this issue Dec 29, 2015 · 10 comments · Fixed by #920
Assignees

Comments

@Bogdaan
Copy link

Bogdaan commented Dec 29, 2015

When i work with css background-image source map generate "Blob" url, and images not loaded from dev-server:

Request URL:blob:http%3A//localhost%3A3000/2454cd1b-a4bb-46fa-8d4b-446ac9b2c9a6   

In style-loader i found this note: output.publicPath

It posible load image from files with current webpack config (with publicPath=/)?

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@pixelcure
Copy link

I'm also experiencing this issue...

@thoughtassassin
Copy link

I am experiencing this issue with fonts that are loaded in the public folder. They are visible on localhost:5000 but on localhost:3000 the fonts show for a fraction of a second and then the styles and the fonts disappear.

@nss213
Copy link

nss213 commented Feb 2, 2016

I just specified the publicPath for the client to work around this. I believe it only shows up in dev mode.

const clientConfig = merge({}, config, {
  entry: [
    ...(WATCH ? ['webpack-hot-middleware/client'] : []),
    './src/client.js',
  ],
  output: {
    path: path.join(__dirname, '../build/public'),

    // need to give absolute URL when using sourcemaps/blobs
    // https://github.com/webpack/css-loader/issues/29
    // https://github.com/webpack/style-loader/issues/55
    publicPath: DEBUG ? 'http://localhost:3000/': '/',

    filename: DEBUG ? '[name].js?[hash]' : '[name].[hash].js',
  },

@Bogdaan
Copy link
Author

Bogdaan commented Feb 11, 2016

@nss213 thanks, this also works

@Ilshidur
Copy link

@nss213 Worked for me :

const clientConfig = merge({}, config, {
  entry: './src/client.js',
  output: {
    path: path.join(__dirname, '../build/public'),
    publicPath: DEBUG ? 'http://localhost:3000/' : '/',
    filename: DEBUG ? '[name].js?[hash]' : '[name].[hash].js',
  },

@arjun-io
Copy link

@nss213 @Ilshidur

Did this break connecting to dev from a mobile device for you guys? When I try to connect to 192.168.....:3000 my mobile console is showing "ERR_CONNECTION_REFUSED" when trying to fetch main.js, but when I take out the public path line all is well.

@Bogdaan
Copy link
Author

Bogdaan commented Feb 13, 2016

@arao456 no, browsersync works fine. But you can try change url-loader to

'url-loader?limit='+(DEBUG? 9999999: 1000),

@arjun-io
Copy link

@Bogdaan that seems to work for me. What also works is setting publicPath to publicPath: DEBUG ? 'http://<192.168...>:3000/' : '/', rather than localhost which leads me to think that perhaps my phone or other external device is trying to load assets from somewhere it doesn't have access too (i.e. it's own localhost?).

@Bogdaan
Copy link
Author

Bogdaan commented Feb 13, 2016

@arao456 yes, of course if you devices are connected via a network - you need external address

@arjun-io
Copy link

@Bogdaan I realize this now, but I guess the point I'm getting at is that the fix using publicPath isn't quite a permanent one so maybe we should look into an alternative? Either way, your fix works, so thanks!

frenzzy added a commit to frenzzy/react-starter-kit that referenced this issue Oct 16, 2016
- Allows to import external css from node_modules (ref kriasoft#510, kriasoft#824)
- Allows to properly process `url()` statements (ref kriasoft#825)
- Allows to import css without css-modules prefixing (close kriasoft#771)

  ```css
  /* Example: MyTextEditorComponent.css */
  :global {
    @import 'draft-js/dist/Draft.css'; /* external style without prefixing */
  }
  .button { color: red; } /* keep the prefixes for your own style */
  ```

Also closes kriasoft#375 and kriasoft#423
frenzzy added a commit that referenced this issue Oct 21, 2016
- Allows to import external css from node_modules (ref #510, #824)
- Allows to properly process `url()` statements (ref #825)
- Allows to import css without css-modules prefixing (close #771)

  ```css
  /* Example: MyTextEditorComponent.css */
  :global {
    @import 'draft-js/dist/Draft.css'; /* external style without prefixing */
  }
  .button { color: red; } /* keep the prefixes for your own style */
  ```

Also closes #375 and #423
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

Successfully merging a pull request may close this issue.

8 participants