Make uniapp files created by HBuilder X support npm commands

Environment installation

// 全局安装vue-cli
npm install -g @vue/cli

Create uni-app

Use the official version (corresponding to the latest official version of HBuilderX)

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

Use the alpha version (corresponding to the latest alpha version of HBuilderX)

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

At this point, you will be prompted to select a project template, which corresponds to the project template created by HBuilder X, as shown below:
Alt

Transform uniapp files created with HBuilder X

  1. Create a new src file in the root directory and put all the files into the src folder.
  2. Open the newly created project and copy the following files to the root directory.
    insert image description here
  3. At this point, the source files created with HBuilder X can use the npm command.

Run and publish uni-app

npm run dev:%PLATFORM% 
npm run build:%PLATFORM%

%PLATFORM%Possible values ​​are as follows:

value platform
app-plus The app platform generates packaging resources (supports npm run build:app-plus, which can be used for continuous integration. Run is not supported, and operation and debugging still need to be operated in HBuilderX)
h5 H5
mp-alipay Alipay applet
mp-baidu Baidu applet
mp-weixin WeChat applet
mp-toutiao ByteDance applet
mp-qq qq applet
mp-360 360 applet
quickapp-webview Quick App (webview)
quickapp-webview-union Quick App Alliance
quickapp-webview-huawei Quick App Huawei

You can customize more conditional compilation platforms, such as the DingTalk applet, refer to the package.json document.

Guess you like

Origin blog.csdn.net/weixin_47949352/article/details/114678379