I am still exploring and learning Angular2 myself. This article introduces the practical operation of angular2+ express packaging and deployment, share it with everyone, and leave a note for myself.
angular is client js and server JS. To establish a SPA website, you need to unify the two.
1. Create an angular2 project, use angular-cli
ng new mypos
2. Use the express command line tool to create an express project.
express --view=hbs
3. In angular2, you need to refer to third-party libraries, such as jQuery, bootstrape,
You need to add the application, and then the file needs to be copied to the assets directory
<linkrel="stylesheet"type="text/css"href="/assets/primeng/resources/themes/bootstrap/" rel="external nofollow" /> <linkrel="stylesheet"type="text/css"href="/assets/primeng/resources/" rel="external nofollow" /> <linkrel="stylesheet"type="text/css"href="/assets/primeng/resources/" rel="external nofollow" /> <scriptsrc="/assets/"></script> <linktype="text/css"href="/assets/bootstrap/css/" rel="external nofollow" rel="stylesheet"> <scriptsrc="/assets/bootstrap/js/"></script>
4. Modify //Specify as the static file directory of express.
"outDir":"express/public/"
5. Packing
ng build --prod
6. Enter the express running directory
npm start
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.