PixelOven.Webpack

Webpack is in many regards a must have for large scale JS Application development. Through it's numerous extensions it also supports many other crucial aspects for web development. The goal of this addon is to abstract a lot of the complex configuration requred to get a solid workflow setup for large scale application development.

This addon is meant to allow the CLI to use webpack as a bundler on top of a a TypeScript compiler. It includes many of the plugins and features expected from a fully production ready JavaScript application. Also included is a completely custom development server built to handle both client and server side JavaScript development.

Installation

Note: the current version of this extension was specifically designed for creating server side rendered react applications. Though our ultimate goal is to provide a more general development platform we want to first nail this subset before conquering others.

To install this addon simply run the following with NPM

npm install --save-dev @pixeloven/cli-addon-webpack

or yarn

yarn add --dev @pixeloven/cli-addon-webpack

API Reference

Note: This API is likely to be broken into a set of more modular APIs in future versions.

APIDescription
webpackCLI entry point for interfacing with Webpack.

NOTICE: This API is likely to be broken into a set of more modular APIs in future versions.

Our webpack CLI Addon builds on top of webpack and many other supporting projects to create a system for developing and building JavaScript applications that scale.

ArgumentRequiredDefaultDescription
<task>YesN/ADetermines how to build Webpack.

Based on the task provided Webpack will be built in one of two modes.

ArgumentDescription
buildBuilds Webpack for production.
startRuns Webpack in watch mode for local development.

Options

These options provide more general customization through webpack. For options specific to Development or Production builds can be found below.

OptionDefaultDescription
--allow-externalsfalseAllows bundling of external dependencies. This is automatic for client builds. Node/Server builds require this to be passed explicitly.
--path/Public path an application will be mounted at. Generally the default value is recommended.
--source-mapfalseSets a flag for webpack to include source mapping.
--circular-dep-checkEnables circular dependency checking

Build Options

OptionDefaultDescription
--profilefalseSets a flag for webpack to output "records" with profiling.
--statsfalseOutput static "stats" via webpack-bundle-analyzer.
--stats-dir./statsProvides directory path for stats output. Generally the default value is recommended.

Start Options

OptionDefaultDescription
--developmentfalseTells Webpack to run in development mode. The default is "production".
--hostlocalhostHost development server will be running on. Generally the default value is recommended.
--ignored/node_modules/Defines a pattern for ignoring paths for file watching.
--pathfalseSets a flag for webpack to output "records" with profiling and stats.
--poll500Set polling frequency. false signifies no polling. Generally the default value is recommended.
--port8080Port to bind development server to.
--protocolhttpExpected protocol for development server.
--statsfalseRun "stats" via webpack-bundle-analyzer in a hosted server.
--stats-hostfalseHost stats server will be running on. Generally the default value is recommended.
--stats-port8081+1Sets the base port for both client and server "stats" using webpack-bundle-analyzer. Requires two consecutive open ports.

It is recommended to keep polling on for cross platform purposes. File watching can be CPU intensive if a system falls back to fs.watchFile versus utilizing file system events with fs.watch. This is common on linux environments.

Usage

To run Webpack in development/watch mode on a specific port you.

yarn run pixeloven webpack start \
--client ./src/client/index.tsx \
--server ./src/server/index.ts \
--allow-externals \
--development \
--source-map \
--host localhost \
--path / \
--port 8080 \
--protocol http

Or build with Webpack for production.

yarn run pixeloven webpack build \
--client ./src/client/index.tsx \
--server ./src/server/index.ts \
--allow-externals \
--stats \
--path /

Of course you can also just use the default values which are recommended.

Last updated on by Brian Gebel