How to use vue-cli to create a project and package it with webpack

How to use vue-cli to create a project and package it with webpack

1. Prepare the environment (download nodejs and set environment variables)
2. Install vue-cli globally and provide vue command to create vue project

npm install -g @vue/cli

About old versions
The package name of Vue CLI was changed from vue-cli to @vue/cli. If you have installed an older version of vue-cli (1.x or 2.x) globally, you need to uninstall it first via npm uninstall vue-cli -g or yarn global remove vue-cli.

3. Create a new project based on the webpack template (first create a new project folder and open the command line at the location)

vue init webpack my-project

4. Perform default configuration

# Some configuration is required here, just press Enter by default This will install Vue 2.x version of the template.

For Vue 1.x use: vue init webpack#1.0 my-project
# Start configuration? Project name my-project
? Project description A Vue.js project
? Author runoob <[email protected]>
? Vue build standalone
? Use ESLint to lint your code? Yes
? Pick an ESLint preset Standard
? Setup unit tests with Karma + Mocha? Yes
? Setup e2e tests with Nightwatch? Yes
# Configuration ends vue-cli · Generated "my-project".

   To get started:
   
     cd my-project
     npm install
     npm run dev
   
   Documentation can be found at https://vuejs-templates.github.io/webpack

5. Enter the project, install node_modules, and start the project

cd my-project
npm install
npm run dev

6. Package the project and configure nginx

#Package project npm run build

nginx configuration

worker_processes 1;

events {
    worker_connections 1024;
}

http {
    include mime.types;
    default_type application/octet-stream;
    sendfile on;
    keepalive_timeout 65;

    server {
        listen 8081;
        server_name localhost;

		location / {
            root E:/vuework/my-project/dist;
			try_files $uri $uri/ /index.html;
            index index.html index.htm;
        }
    }
}

7. Repeated packaging, file not updated.
Reference the clean-webpack-plugin plug-in in the webpack package file in the build directory, and then use it in the plugin.

insert image description here
insert image description here
insert image description here

8. Deployment: configure nginx, package the project, and start nginx

npm run build
start nginx

This is the end of this article about using vue-cli to create a project and webpack packaging. For more related vue webpack packaging content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed explanation of different packaging commands for different vue environments
  • Detailed explanation of vue project packaging steps
  • Detailed explanation of Vue project packaging
  • Configure your own startup command and packaging command method in the Vue project

<<:  Mysql WorkBench installation and configuration graphic tutorial

>>:  MySQL Workbench download and use tutorial detailed explanation

Recommend

Several solutions for forgetting the MySQL password

Solution 1 Completely uninstall and delete all da...

How to implement remote access control in Centos 7.4

1. SSH remote management SSH is a secure channel ...

Detailed steps to install MySQL 5.6 X64 version under Linux

environment: 1. CentOS6.5 X64 2.mysql-5.6.34-linu...

How to implement the King of Glory matching personnel loading page with CSS3

Those who have played King of Glory should be fam...

Implementation of docker-compose deployment project based on MySQL8

1. First, create the corresponding folder accordi...

Realize breadcrumb function based on vue-router's matched

This article mainly introduces the breadcrumb fun...

How to shut down/restart/start nginx

closure service nginx stop systemctl stop nginx s...

Color matching techniques and effect display for beauty and styling websites

Color is one of the most important elements for a...

Detailed explanation of mixins in Vue.js

Mixins provide distributed reusable functionality...

MySQL decimal unsigned update negative numbers converted to 0

Today, when verifying the concurrency problem of ...

Directory permissions when creating a container with Docker

When I was writing a project yesterday, I needed ...

Detailed explanation of how to use the Vue date time picker component

This article example shares the specific code of ...

How to use node to implement static file caching

Table of contents cache Cache location classifica...