The uni-app project is converted from hbuilder project to cli project

1.Background

The original uni-app project was created through hbuilder, and its operation and packaging depend on hbuilder. Generally, it is developed in vscode, and running on hbuilder is weird. Later, I hope to run without hbuilder and package it through the build platform, so I converted the hbuilder project for cli project

2. Steps

1. Install cli (skip the original cli)

npm install -g @vue/cli

2. Create an empty project through cli

For this part, please refer to the uni-app official website

vue create -p dcloudio/uni-preset-vue my-project

3. Migrate original project content

  • Create the src folder in the root directory of the newly created my-procject project
  • Put all the files of the original project into the newly created src folder. Among them node_modules, unpackage, package.json, package-lock.jsonare not needed and do not need to be placed.
  • Compare the contents of the original project package.jsonand the new one , and write in package.jsonthe additional packages required by the original project.package.json
  • npm installInstall additional packages

Less is originally supported by hbuilder itself. After creating a project through cli, you need to install less additionally. At this time, you need to pay attention to the issue of the less version. Directly npm install lessinstalled packages may cause the following problems. ValidationError: webpack Dev Server Invalid Options options should NOT have additional properties
This may be that different versions of less have requirements for webpack configuration, and some configurations are not supported in uni-app, so you need to install the specified version. Install The following less versions can solve the above problems"less": "^3.9.0", "less-loader": "^4.1.0",

Guess you like

Origin blog.csdn.net/qq_44242707/article/details/132598424