-
Notifications
You must be signed in to change notification settings - Fork 505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
webui: demonstrate building a standalone page based on Vue.js implementation #2172
Comments
To start off, we need to first create a Vue application named
Note: we can use any package manager: This will create a template Hello World web application, next we need to install our library of choice PrimeVue and its peer dependencies:
The entry point of the application is found in
When the build is done, a We can ship this However, if we want to create a seperate release, for users who want to use capa offline without having to spin local server we need to add a plugin for this purpose (we cannot simply download the To solve this, we need to use vite-plugin-singlefile: it is a plugin to create a standalone
The Note: the resulting file is not meant to be edited manually. You should edit |
Neat, thanks for the details and documentation. The resulting standalone HTML looks good and is exactly what I had in mind. As next step, I'd suggest to either:
|
Building a standalone index.html using Github workflowsIn a vite-based project, we specify how we'd like to build the web app using the The default template of import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
export default defineConfig({
base: '/capa-webui',
plugins: [vue()]
}) However, for our use case, we'd like to add a conditional build step to use a the vite-plugin-singlefile plugin to build the app as a standalone offline app. To achieve this, we need to adjust import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { viteSingleFile } from 'vite-plugin-singlefile'
export default defineConfig(({ command, mode }) => {
const isBundle = mode === 'bundle'
return {
base: isBundle ? '/' : '/capa-webui',
plugins: isBundle ? [vue(), viteSingleFile()] : [vue()]
}
}) Here, we introuce a new step which will be used to decide if this a normal build (i.e. Finally we need add the new build step in our {
"scripts": {
"build": "vite build",
"build:bundle": "vite build --mode bundle",
}
}
PS: @williballenthin I looked into monolith, but couldn't get it to work. Will investigate more. For now, this approach works. |
Let's show how easy/hard it is to build a standalone offline webpage to display capa results.
The text was updated successfully, but these errors were encountered: