简体   繁体   中英

Import TypeScript class dynamically

I'm trying to load TypeScript class dynamicaly. But after compilation browser says there is 404 error. Browser tries to load file from the project root. But I need to load it from directory that differs from root. How can I configure it?

浏览器找不到文件

webpack.config.js :

webpack.config.js

tsconfig.json :

tsconfig.json

I tried to look for issues in the web. But I found nothing. Thanks in advance!

Wepback has publicPath configuration that represents destination root inside the project. So dynamically loading modules is going to be looked at this directory.

I found this information here: http://code.fitness/post/2016/02/webpack-public-path-and-hot-reload.html

webpack.config.js after updating:

webpack.config.js

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM