This is the starter template to develop Modules of App type for Fluidspace.
It is recommended to use this as the base for any new module development for consistent and smoother development experience.
More...
This template contains basic code structure including the Factory, API controller and environment simulation definitions.
The template uses Vue 3 + Vite and trimmed-down version of JS files that are used on Fluidspace to invoke and handle modules.
The Vite bundling and build configuration are already defined, we recommend to not change any of it.
The final build is an IIFE with .js in dist/js/ and all the static assets in dist/assets/ directory. Due to the nature of current build process, the built (dist) files may not be directly servable (i.e. independent of Fluidspace Environment).
Configuring & using template video guide: YouTube
- Installed and running Fluidspace Development Server
- Node.js v18+
- Copy of this repo
git clone https://github.com/FluidspaceWeb/app-template-vue3.git
If your module needs database
Navigate to the Fluidspace Development Server web page (default localhost:1822) and create a new collection for your module's data.
Generate random module ID
Click the generate module ID button and copy it.
Note: This ID is only for development purpose and will be changed automatically when publishing to fluidspace marketplace via the developer platform (coming soon).
-
Open the index.html and set the following parameters:
{ "serverUrl": "http://localhost:1822", "module": { "id": "<valid module id>", "namespace": "<namespace>", "name": "<modulename>", "displayName": "<My Module>" } }
If the module uses database then ensure
namespace
andname
matches the Database collection name. -
Open main.js and set the namespace and modulename in the following line:
customElements.define("module-<namespace>_<modulename>", ...)
-
Similarly, open App.ce.vue and set in namespace and mod_name in
onMounted()
. -
Open Factory.js and set the
MODULE_ID
to the generated ID from previous step.
npm install
npm run dev
Ignore the testbench.js warning: Failed to load url /testbench.js...
Please set the
_MODULES_CDN_BASE_URL
with your namespace and modulename in vite.config.js before building and submitting request to upload fluidspace.app.
npm run build
-
Keep the module concise in terms of features and capabilities. Better to split the features as separate module if not directly related and, use all the modules together as companion.
-
Remember that multiple instance of same module may be loaded simultaneously, which overrides the global or file level variables. Therefore, use OOP approach to create instance of such variables in App.ce.vue and pass the instantiated object as props or
provide/inject
. -
The sub-components do not require
.ce.vue
file extension and it is recommended to use only.vue
. -
The Vite build includes Vue framework and must not be made external. We know that this increases the file size but allows usage of different versions and frameworks in the same Space.
-
There are some known issues with hot-reload not triggering for CSS changes, until then prefer manual refresh.
-
Using
<style>
in sub-components does not work correctly, until then keep.css
separate and import as many as required in App.ce.vue. Example:<style type="text/css" src="@/assets/base.css" />
Fluidspace supports launching of multiple instances of the module which requires Factory to be encapsulated for each instance.
The App.ce.vue uses Vue's provide()
to make the instantiated Factory injectable in any component using inject('FACTORY')
.
Note: inject does not support type-check.
Email me on [email protected] along with the module files for review and publishing.
The online developer platform is currently under development 😅 and should be live soon.
- Type definition
- Template as npm package
- Testbench toast alert support
- Improve path definition for static assets