Pass angular project to production

1

I'm trying to export the project to production, but it only works when I put it in the root of the server.

If, for example, I put it in localhost/dist it does not work anymore.

I have tried to modify the route with the command ng build --base-href=/dist --prod , but, although the modifier still does not work, therefore, I understand that something I am doing wrong.

The idea is to be able to export the project to be able to use it in a route that is not the base of the server, since I need to put it in several different folders, one per client.

I've managed to make it look like <base href="http://localhost/Proyecto/dist/">

But I do not link the images well, I understand that it is because the code is bad in code, but if I run the webpack live server it looks good (npm start)

<!doctype html>
<html lang="es">

<head>
    <meta charset="utf-8">
    <title>Proyecto</title>
    <base href="http://localhost/Proyecto/dist/">

    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" type="image/x-icon" href="favicon.ico">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/all.css" integrity="sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ" crossorigin="anonymous">
    <link rel="stylesheet" href="styles.734eae50a5c982a6cd75.css">
</head>

<body>
    <app-root></app-root>
    <script type="text/javascript" src="runtime.a66f828dca56eeb90e02.js"></script>
    <script type="text/javascript" src="polyfills.7a0e6866a34e280f48e7.js"></script>
    <script type="text/javascript" src="scripts.95f63946aa03ea45d109.js"></script>
    <script type="text/javascript" src="main.c686d7d3bc65f8946dda.js"></script>
</body>

</html>
    
asked by Diego 22.10.2018 в 13:21
source

2 answers

0

I had to put the web route, with HTTPS, it works perfectly, I do not know if it's the right thing to do, but it's the only solution that has worked correctly for me.

    
answered by 06.11.2018 / 13:01
source
0

I also had the same problem, the solution for me was to leave empty base . That is:

<!doctype html>
<html lang="es">

<head>
    <meta charset="utf-8">
    <title>Proyecto</title>
    <base href="">

    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" type="image/x-icon" href="favicon.ico">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/all.css" integrity="sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ" crossorigin="anonymous">
    <link rel="stylesheet" href="styles.734eae50a5c982a6cd75.css">
</head>

<body>
    <app-root></app-root>
    <script type="text/javascript" src="runtime.a66f828dca56eeb90e02.js"></script>
    <script type="text/javascript" src="polyfills.7a0e6866a34e280f48e7.js"></script>
    <script type="text/javascript" src="scripts.95f63946aa03ea45d109.js"></script>
    <script type="text/javascript" src="main.c686d7d3bc65f8946dda.js"></script>
</body>

</html>

I hope you serve, greetings

    
answered by 22.10.2018 в 18:06