UNPKG

@electrojet/core

Version:

Build scripts for use with create-electrojet

101 lines (69 loc) 1.95 kB
<div align="center"> <h1>Electrojet Web Core</h1> <a href="https://badge.fury.io/js/%40electrojet%2Fcore"><img src="https://badge.fury.io/js/%40electrojet%2Fcore.svg" alt="npm version" height="18"></a> <p>A CLI for running applications generated by <a href="https://www.npmjs.com/package/create-electrojet">create-electrojet</a></p> </div> ## Commands ### 1. Start Starts a development server using webpack. ``` core-scripts start --port=4567 ``` Port is defaulted to 4567. ### 2. Build Builds using webpack build configuration to the dist folder ``` core-scripts build ``` ## Node API ### 1. Start Starts the webpack dev server in development mode. Returns a promise on completion. Fails loudly on error. ```js const core = require("@electrojet-core"); // Your function that runs on start command async function start() { await core.start({ flags: { port: 4567, // Port for developement server }, plugins: [ { resolve: (env, context, options) => {} // Same as plugins in electrojet.config.js } ] }); } ``` ### 2. Build Runs webpack build. Returns a promise on completion. Fails loudly on error. ```js const core = require("@electrojet-core"); // Your function that runs on build command async function build() { await core.build({ plugins: [ { resolve: (env, context, options) => {} // Same as plugins in electrojet.config.js } ] }); } ``` ### 3. `getConfig` Gets the configuration object defined in `electrojet.config.js` at root. Returns a Promise with options. ```js const { getOptions } = require('@electrojet/core'); async function doSomething() { const options = await getConfig; } ``` ## What are the default options? * [Common Config]() These are common for both development and production. * [Development Config]() These are enabled only in development. * [Production Config]() These are enabled only in production.