CLI
#
1. OverviewUnder the hood, CellularJS's CLI make use of Webpack to help developer run dev server and create separate deployable bundles.
#
2. cellular.ts// cellular.tsimport { CellularConfig } from '@cellularjs/cli';
const cellularConfig: CellularConfig = { entry: { halo: './src/$gateway/halo/index.ts', worker: './src/$gateway/worker/index.ts', }, webpack: (config) => { // config.plugins.push(WebpackPlugin);
return config; }};
export default cellularConfig;
entry
: key-value of entry name and the path to entry source. You will see how to use entry in the next section.webpack
: you can edit Webpack configuration with this config like above example.
#
3. Command#
3.1. Run dev serverExample 1: run a single entry
// package.json"scripts": { "dev:halo": "cellular dev -e halo"}
yarn dev:halo
#
3.2. Build codeExample 1: build a single entry.
// package.json"scripts": { "build:halo": "cellular build -e halo"}
yarn build:halo
Example 2: create 3 separate deployable bundles.
// cellular.tsimport { CellularConfig } from '@cellularjs/cli';
const cellularConfig: CellularConfig = { entry: { user: './src/$gateway/user/index.ts', mailer: './src/$gateway/mailer/index.ts', all_others: './src/$gateway/main-app/index.ts', // ... },};
// package.json"scripts": { "build:all": "cellular build -e article mailer all_others"}
yarn build:all