Home >Web Front-end >JS Tutorial >Detailed explanation of the steps to directly develop PWA applications using @angular/cli V6.0
This time I will bring you a detailed explanation of the steps to directly develop PWA applications using @angular/cli V6.0. What are the precautions for using @angular/cli V6.0 to directly develop PWA applications? The following are Let’s take a look at practical cases.
What is PWA
PWA (Progressive Web App) utilizes TLS, webapp manifests and service workers to enable applications to install and use it offline. In other words, a PWA is like a native app on your phone, but it's built using web technologies like HTML5, JavaScript, and CSS3. When built correctly, PWAs are indistinguishable from native apps. The main features of PWA include the following three points:
Angular has officially released V6.0, and we can already use the corresponding @angular/cli V6.0 to directly develop PWA applications. Not much to say below, let’s take a look at the detailed introduction.
Step one: Install @angular/cli V6.0If you have an old version on your machine, please uninstall it first.
Open your terminal and execute:
npm install -g @angular/cli
After successful installation, use ng -v to check the version number:
##Second step: new an empty projectExecution:
ng new test-ng-pwaAfter the creation is successful, take a look at the project and execute:
ng serve --openSeeing this interface in the browser means everything is OK: Step 3: Add PWA support
Stop the project, and then execute it in the terminal:
ng add @angular/pwaThe effect is as follows: ##Because the built-in Server of @angular/cli is compiled with --prod Service-worker was not supported at that time, so a third-party lite-server was installed on it. Its official documentation is here:
https://npmjs.com/package/lite-server, please execute :
npm install lite-server --save-dev npm install lite-server --global
After installation, execute: npx ng build --prod && lite-server --baseDir dist/test-ng-pwa
Then open your browser to access port 3000. You can see that the service-worker has started successfully:
Recommended reading:
How to view personal information and change password in vueWhat BUGs and errors often occur in JS
The above is the detailed content of Detailed explanation of the steps to directly develop PWA applications using @angular/cli V6.0. For more information, please follow other related articles on the PHP Chinese website!