简体   繁体   中英

Ionic 4 npm run build --prod not working when hosting on Apache server

This is my first project on Ionic 4, I have been working in Ionic 3 till now and I use to make builds for web with the command

npm run build --prod

But when I am making the build in Ionic 4 project using the same command, it is generating a lot of js and map files, around 400 or more files in the www folder

0-es5.js , 0-es5.js.map , 0-es2015.js , 0-es2015.js.map till 77-es5.js.... and then my actual pages

在此处输入图片说明

Now when I upload this on my hosting [Apache server] and run, it is not working and is giving error, it's looking for files outside the folder where I have uploaded, I uploaded it in domain.com/folder but it's looking in domain.com/ .

See this pic:

在此处输入图片说明

在此处输入图片说明

You need to change <base/> in www/index.html to

<base href="qanda">

If base href is like <base href="/" /> then index.html trying to find assets files like css, js from root of your hosting domain.

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