0

I want to deploy my angular project in IPFS so I want to know if is possible to launch an angular project without any http server, like static html, css and js template?

maroodb
  • 1,026
  • 2
  • 16
  • 28

2 Answers2

0

Don't know much about IPFS, but an Angular prod build is just simple HTML + JS files. You can even bundle them together into one file as well. An Angular application instance can exist only in the user's browser alone (in Browser mode).

ForestG
  • 17,538
  • 14
  • 52
  • 86
  • it seems like building angular project in one file isn't supported directly by the angular CLI, I look for it. thanks :) – maroodb Apr 18 '18 at 09:24
  • you might need to do a little scripting. https://stackoverflow.com/questions/42933220/how-to-get-one-file-as-output-of-angular-cli I belive you can then copy+paste the .js file contnet into the html directly with a – ForestG Apr 18 '18 at 10:03
  • I need to make all scripts in the index file. to deploy it in IPFS as a single file. – maroodb Apr 20 '18 at 08:37
  • after you create it, just copy the content from the .js files to the middle of the html file between an ` – ForestG Apr 20 '18 at 10:08
0

You can publish the angular app as it is. But because there is no web server behind ipfs, you have to use HashLocationStrategy in the app routing:

RouterModule.forRoot(routes, {useHash: true})

(by default angular uses PathLocationStrategy which requires a web server to serve all nested routes to origin app html file)

Diomas
  • 58
  • 5