8000 fix(webpack): Images are not being loaded using webpack-dev-server · d4rkr00t/aik@84f8a68 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 84f8a68

Browse files
committed
fix(webpack): Images are not being loaded using webpack-dev-server
Ugly hack which solves an issue with not loading images with generated urls in css files. Related issues: webpack-contrib/style-loader#96
1 parent e400403 commit 84f8a68

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

lib/webpack/assets/public-path.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict';
2+
3+
/**
4+
* Ugly hack which solves an issue with not loading images with generated urls in css files.
5+
* This file loads up before entry point and dynamically sets public path to, for example, "http://localhost:4444/".
6+
* Depends on current phost and port. And also it works well with ngrok exposed servers.
7+
*
8+
* Related issues: https://github.com/webpack/style-loader/pull/96
9+
*/
10+
__webpack_public_path__ = window.location.protocol + '//' + window.location.host + '/'; // eslint-disable-line

lib/webpack/entry.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function entryDev(filename, flags) {
4747
const host = flags.host === '::' ? 'localhost' : flags.host;
4848

4949
return {
50-
[entryName]: [`${ require.resolve('webpack-dev-server/client') }?http://${ host }:${ flags.port }/`, require.resolve('webpack/hot/dev-server'), (0, _resolveToCwd2.default)(filename)]
50+
[entryName]: [require.resolve('./assets/public-path.js'), `${ require.resolve('webpack-dev-server/client') }?http://${ host }:${ flags.port }/`, require.resolve('webpack/hot/dev-server'), (0, _resolveToCwd2.default)(filename)]
5151
};
5252
}
5353

src/webpack/assets/public-path.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* Ugly hack which solves an issue with not loading images with generated urls in css files.
3+
* This file loads up before entry point and dynamically sets public path to, for example, "http://localhost:4444/".
4+
* Depends on current phost and port. And also it works well with ngrok exposed servers.
5+
*
6+
* Related issues: https://github.com/webpack/style-loader/pull/96
7+
*/
8+
__webpack_public_path__ = window.location.protocol + '//' + window.location.host + '/'; // eslint-disable-line

src/webpack/entry.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export function entryDev(filename: string, flags: CLIFlags): Entry {
3434

3535
return {
3636
[entryName]: [
37+
require.resolve('./assets/public-path.js'),
3738
`${require.resolve('webpack-dev-server/client')}?http://${host}:${flags.port}/`,
3839
require.resolve('webpack/hot/dev-server'),
3940
resolveToCwd(filename)

0 commit comments

Comments
 (0)
0