Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat(web): add env file to support configuration of BASE_URL #1619

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .github/workflows/deploy_web.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ jobs:
with:
node-version-file: '.nvmrc'

- name: set env
run: |
cd web
echo "VUE_APP_PAGE_TITLE=Easy-to-Use Online MQTT Client | Try Now" > .env.local
echo "VUE_APP_PAGE_DESCRIPTION=Online MQTT 5.0 client on the web, using MQTT over WebSocket to connect to the MQTT Broker and test message publishing and receiving in the browser." >> .env.local

- name: build
run: |
cd web
Expand All @@ -49,12 +43,6 @@ jobs:
with:
node-version-file: '.nvmrc'

- name: set env
run: |
cd web
echo "VUE_APP_PAGE_TITLE=Easy-to-Use Online MQTT Client | Try Now" > .env.local
echo "VUE_APP_PAGE_DESCRIPTION=Online MQTT 5.0 client on the web, using MQTT over WebSocket to connect to the MQTT Broker and test message publishing and receiving in the browser." >> .env.local

- name: build
run: |
cd web
Expand Down
7 changes: 7 additions & 0 deletions web/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
VUE_APP_PAGE_TITLE=Easy-to-Use Online MQTT Client | Try Now
VUE_APP_PAGE_DESCRIPTION=Online MQTT 5.0 client on the web, using MQTT over WebSocket to connect to the MQTT Broker and test message publishing and receiving in the browser.

VUE_APP_DEFAULT_HOST=broker.emqx.io

BASE_URL=/online-mqtt-client/
VUE_APP_OUTPUT_DIR=dist/online-mqtt-client
7 changes: 7 additions & 0 deletions web/.env.docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
VUE_APP_PAGE_TITLE=Easy-to-Use Online MQTT Client | Try Now
VUE_APP_PAGE_DESCRIPTION=Online MQTT 5.0 client on the web, using MQTT over WebSocket to connect to the MQTT Broker and test message publishing and receiving in the browser.

VUE_APP_DEFAULT_HOST=broker.emqx.io

BASE_URL=/
VUE_APP_OUTPUT_DIR=dist
2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"build:docker": "export BUILD_MODE=docker && vue-cli-service build",
"build:docker": "vue-cli-service build --mode docker",
"start": "vue-cli-service build && http-server dist -o /online-mqtt-client",
"test:e2e": "vue-cli-service test:e2e",
"lint": "vue-cli-service lint"
Expand Down
2 changes: 1 addition & 1 deletion web/src/utils/mqttUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export const getDefaultRecord = (): ConnectionModel => {
name: '',
clean: true,
protocol: 'ws',
host: 'broker.emqx.io',
host: process.env.VUE_APP_DEFAULT_HOST ?? 'broker.emqx.io',
keepalive: 60,
connectTimeout: 10,
reconnect: true,
Expand Down
6 changes: 2 additions & 4 deletions web/vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin')

process.env.VUE_APP_VERSION = require('./package.json').version

const buildMode = process.env.BUILD_MODE

module.exports = {
publicPath: buildMode === 'docker' ? '/' : '/online-mqtt-client/',
outputDir: buildMode === 'docker' ? 'dist' : 'dist/online-mqtt-client',
publicPath: process.env.BASE_URL,
outputDir: process.env.VUE_APP_OUTPUT_DIR,
configureWebpack: {
plugins: [
new MonacoWebpackPlugin({
Expand Down
Loading