Skip to content
This repository was archived by the owner on Apr 7, 2022. It is now read-only.

feat(scripts/start): add on-demand modules build when start - #32

Open
seikatsurugi wants to merge 1 commit into
masterfrom
f_martinock_add_on_demand_modules_build
Open

feat(scripts/start): add on-demand modules build when start#32
seikatsurugi wants to merge 1 commit into
masterfrom
f_martinock_add_on_demand_modules_build

Conversation

@seikatsurugi

@seikatsurugi seikatsurugi commented Apr 26, 2019

Copy link
Copy Markdown

Provide args when start the apps in development mode #1

command: yarn start --module my_module1,my_module2.

Note:

  1. Providing no arguments means we will build ALL modules.
  2. This arguments will only works on development environment.

PS: This script refer modules name from src/_route/route.js and to make this on-demand module bundling works you need to give module folder names (@page/<module_folder_name>) and variable names in /src/_route/path.js the same name as your defined modules name with the corresponding conventions (upper case for path variable names). See the examples below

example:

// src/_route/route.js
import { WELCOME, SECOND } from "./path";

const route = [
    {
        /** 
         * IMPORTANT: This name is the source of all conventions. 
         * Use it in arguments, as a folder name of your modules,
         * and as your path variable names.
         */
        name: "welcome",
        path: WELCOME,
        exact: true,
        disabled: true
    },
    {
        name: "second",
        path: SECOND,
    },
];

export default route;
// src/_route/module.js
/** 
 * IMPORTANT: the scripts will refer to your modules like this (@page/<module_name>).
 * You need to create the folder in the corresponding path
 */
import Welcome from "@page/welcome";
import Second from "@page/second";

import { WELCOME, SECOND } from "./path";

const module = {
    [WELCOME]: Welcome,
    [SECOND]: Second
};

export default module;
// src/_route/path.js 
export const WELCOME = "/"; // IMPORTANT: name your variables with upper case like this
export const SECOND = "/second";

I would be open for any discussions! So please take time to review it

provide args when start the apps (development) `yarn start --module my_module1,my_module2,`. This
arguments will only works on development environment. This script refer modules name from
`src/_route/route.js` and we recommend you to give module folder names (@page/<module_name>),
variable names in `/src/_route/path.js` and `/src/_route/module.js` the same name with the
corresponding conventions

re #1
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant