This is not a duplicate question:This question explains the problem, but this project was not built with angular-cli, since mine, therefore, I do not have a file webpack.config.
While the problem I am talking about below clearly indicates that base_url is configured correctly, this is not the same as this problem , which is setting angular to send requests to base_url as an api.
My project is built and launched on localhost, as well as on github:pages(even css everything loads correctly). The only thing that does not work on github: pages are images that return 404s (even if I can see them, if I go to the resource folder directly in the browser).
The problem is that on localhost angular-cli starts the project without a subfolder after the host name. But on github:pageshe does.
Let's say, for example, the name of the project testapp, and then github:pagesit is expanded here:
https:
Images are in
src/assets/images
They reference css inside the angular -2 component, using relative paths as follows:
background-image: url('../../assets/images/dining-room.png');
So, how do I configure the angular -2 production deployment file so that during the creation process the path becomes:
background-image: url('testapp/assets/dining-room.png');
, github:pages Jekyll, , , angular -cli, , github:pages .
1, github:pages base_href. :
ng github-pages:deploy --base-href /testapp/
/dist, html , href, :
<base href="/testapp/">
, , 404. base_href , . index.html <base href="/"> , , .
2, , , angular . .
EDIT angular -cli.json{
"project": {
"version": "1.0.0-beta.22-1",
"name": "floorbook"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"test": "test.ts",
"tsconfig": "tsconfig.json",
"prefix": "fb",
"mobile": false,
"styles": [
"styles.css"
],
"scripts": [],
"environments": {
"source": "environments/environment.ts",
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"addons": [],
"packages": [],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"prefixInterfaces": false,
"inline": {
"style": false,
"template": false
},
"spec": {
"class": false,
"component": true,
"directive": true,
"module": false,
"pipe": true,
"service": true
}
}
}