Deploy straight to VK Mini Apps hosting with one simple command.
# install it from npm and symlink it into your PATH
npm install @vkontakte/vk-miniapps-deploy -g
# now run it!
vk-miniapps-deploy
You can also use npm run
to package it with your app without installing it globally.
First add this to your scripts section of package.json
:
"scripts": {
"deploy": "vk-miniapps-deploy",
"clean-source": "rimraf README.md src webroot package.json"
},
And then install vk-miniapps-deploy
as a devDependency:
npm install @vkontakte/vk-miniapps-deploy --save-dev
And now you can run npm run deploy
to run the vk-miniapps-deploy
installed in the local node_modules
folder (even if you have never done npm install vk-miniapps-deploy -g
).
To configure vk-miniapps-deploy
all you need to do is specify a couple of things in your vk-hosting-config.json
{
"static_path": "build",
"app_id": "...",
"endpoints": {
"mobile": "index.html",
"mvk": "index.html",
"web": "index.html"
}
}
- Make sure that in package.json the key value «homepage» is «./»
- Copy the example config to the root folder of your application vk-hosting-config.json.example and remove the suffix «.example»
- Run yarn deploy
CI/CD is automatically detected, you only need to pass access_token
to env:
$ cross-env MINI_APPS_ACCESS_TOKEN=<token> yarn deploy
with user token retrieved from vk-miniapps-deploy OR service token of deployable application
There are two values to specify MINI_APPS_ENVIRONMENT: production
or dev
.
All production builds will be also deployed on dev environment.
If you grep URL paths, you can use environment variable CI_URLS = true
.
URLs will be printed as followed structure (⇆ is tab character):
# development
vk_app_desktop_dev_url:⇆url
vk_app_dev_url:⇆url
vk_mini_app_mvk_dev_url:⇆url
# production
iframe_secure_url:⇆url
m_iframe_secure_url:⇆url
vk_mini_app_mvk_url:⇆url
See URL_NAMES for more information.
If you always need to run in CI/CD-mode, in config:
{
"noprompt": true
}
If you get an error Access token is invalid
, try this comand:
rm ~/.config/configstore/@vkontakte/vk-miniapps-deploy.json