vue 部署 abap BSP

How to Create a Vue.Js App with VS Code and Deploy... - SAP Community

详情见上面这个教程连接

Open VS Code and open a terminal window and run

npm install -g @vue/cli


restart vscode.

Open a terminal window again and go to your workspace folder to create the app and app folder with following command. And choose V3.

vue create vue-abap-app


if you get following error -> File C:\Users\xxx\AppData\Roaming\npm\vue.ps1 cannot be loaded
because running scripts is disabled on this system. For more information, see 

Run Set-ExecutionPolicy RemoteSigned  and re-try vue create vue-abap-app

This time you should see new folder and files in your workspace.


Now you can run Vue app. Go to vue-abap-app folder and run.

cd .\vue-abap-app\
npm run serve


You can open a browser and enter following URLS to reach Vue app.

- Local: http://localhost:8080/
- Network: http://192.168.93.237:8080/

You should see screen below.


Our app is ready and running. To stop npm server go to vscode terminal and pres ctrl + c and yes ro stop server.


Now we need to install another tool, ui5uploader, to deploy any js app to SAP Netweaver.

npm install -g nwabap-ui5uploader 


go to root folder of your app and create a '.nwabaprc' file.


Content can be like below, details of SAP connection and publication.

I will be publishing it to my SAP server which runs on Ubuntu virtualbox. That is developer edition. Here is a link with video tutorial if you want to install SAP at home 

:slightly_smiling_face:

{ 
    "base": "./dist", 
    "conn_usestrictssl": false, 
    "conn_server": "http://127.0.0.1:8000/", 
    "conn_client": "001", 
    "conn_user": "developer", 
    "conn_password": "Down1oad", 
    "abap_package": "$TMP", 
    "abap_bsp": "ZVueAbapApp", 
    "abap_bsp_text": "Vue App for SAP" 
} 


Before we build and deploy we need to make sure, we provide production path for source files. Our app will be running on SAP with URL address of 'http://127.0.0.1:8000/sap/bc/ui5_ui5/sap/zvueabapapp/index.html?sap-client=001'. We need to tell vue to look sources under '/sap/bc/ui5_ui5/sap/zvueabapapp/'. Open vue config.js and add following code.

  publicPath: process.env.NODE_ENV === 'production'
    ? '/sap/bc/ui5_ui5/sap/zvueabapapp/'
    : '/'


It should look like below.


Note: that app name is determined in '.nwabaprc' file. If you change app name please change that part too.

 

Now time to build again and deploy to SAP.

npm run build


And deploy to SAP

npx nwabap upload


 

Now, we can see our app in BSPs on SAP.


And also in SICF and test it from there.


Browser will open and should like exactly same as as the page served from local server.

http://vhcalnplci:8000/sap/bc/ui5_ui5/sap/zvueabapapp/index.html?sap-client=001


That is it.

Very simply you can do Vue development and publish it to SAP Netweaver.

In next post, I will show how to create a rest api with abap and use it with vue. I personally don't like oData. I think rest is much more practical and easier to develop and extend. Read my blog on MVC1 applied rest api.  And unfortunately same is true for Fiori. Vue is much more elegant and easier to understand and develop compare to Fiori. Therefore if I can choose one, I will choose Rest + Vue combination.

  • 11
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Vue.js是一个流行的JavaScript框架,用于构建用户界面。Docker是一种容器化技术,可以将应用程序及其依赖项打包到一个可移植的容器中,以便在不同的环境中运行。将Vue.js应用程序部署到Docker中,可以使应用程序更易于部署和管理。 下面是Vue.js部署Dockerfile的步骤: 1. 创建一个Dockerfile文件,其中包含以下内容: ``` # 基础镜像 FROM node:12.16.1-alpine # 设置工作目录 WORKDIR /app # 复制package.json和package-lock.json文件 COPY package*.json ./ # 安装依赖项 RUN npm install # 复制所有文件到工作目录 COPY . . # 构建应用程序 RUN npm run build # 设置nginx配置文件 COPY nginx/default.conf /etc/nginx/conf.d/default.conf # 启动脚本 COPY start.sh /start.sh RUN chmod +x /start.sh # 暴露端口 EXPOSE 80 # 启动nginx和应用程序 CMD ["/start.sh"] ``` 2. 在Vue.js项目的根目录中创建一个名为start.sh的文件,其中包含以下内容: ``` #!/bin/sh set -e # 启动nginx nginx -g 'daemon off;' # 启动应用程序 npm run serve ``` 3. 在项目根目录中创建一个名为nginx的文件夹,并在其中创建一个名为default.conf的文件,其中包含以下内容: ``` server { listen 80; server_name localhost; location / { root /app/dist; index index.html; try_files $uri $uri/ /index.html; } } ``` 4. 在项目根目录中运行以下命令来构建Docker镜像: ``` docker build -t my-vue-app . ``` 5. 运行以下命令来启动容器: ``` docker run -p 80:80 my-vue-app ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值