Setting __webpack_public_path__ does not reflect while importing images

Hello,

In my entry(main.js) file I have set __webpack_public_path__ at the first line as below

__webpack_public_path__ = 'http://some.cdn.com/some'

but while import images it just return the name

import SomeFriend from '../../images/some-friend';
(the above import is done in b.js which will be imported in main.js)

I even tried it setting next to the import

__webpack_public_path__ = 'http://some.cdn.com/some'
import SomeFriend from '../../images/some-friend';

when I do console.log(SomeFriend) it returns the file name as some-friend.jpg

Need experts advice. How to set __webpack_public_path__ so that all my image will be loaded from the give location.

Thanks & Regards
Adi

Author: Fantashit

1 thought on “Setting __webpack_public_path__ does not reflect while importing images

  1. import is hoisted, so it always runs before the code inside of your module.

    You probably have the use require in the entry point.

Comments are closed.