# FrontEnd Installation

# Folder & Main Class creation

  1. Pick a name for your module (lower_case)
  2. Go to /modules and create a folder with the name of your module
  3. Create a Js file with your module name inside the new folder /modules/module_example/module_example.js
  4. Create your Module class by extending the ModuleBase class
import ModuleBase from "@/modules_loader/ModuleBase";

class Module_example extends ModuleBase {

	name = "module_example";

	cartTypes = [
		"CUSTOM_ITEM_TYPE",
	];

	init(context, app) {
		this.ctx = context;
		this.app = app;

		//To enable/disable the module without socket Data
		this.enabled = false;
	}

	loadSocket(socketOn, context) {
		//To enable/disable the module with socket Data
		socketOn("module_example_activation", async (data) => {
			this.enabled = data;
		});
	}

}

export default Module_example;

# Importing the Module

To load a module it shouuld be loaded in two places, The folder structure wich is managed by LightMerger, and in the runtime by the NuxtJs app.

  1. Example of loading the module_example Module in /plugins/modules.js:

    import modules from "@/modules_loader/modules_loader";
    import module_example from "@/module_example";
    modules.load(module_example);
    
    export default ({ app }, inject) => {
    	inject('modules', modules);
    }
    
  2. Example of loading the module_example Module in /light-merger.json:

    "merges": [
    	{
    		"path": "@"
    	},
    	{
    		"path": "@/modules/pcv_v1"
    	},
    	{
    		"path": "@/modules/module_example"
    	}
    ],