@financial-times/dotcom-page-kit-cli
The Page Kit CLI
Last updated 19 days ago by the-ft .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install @financial-times/dotcom-page-kit-cli 
SYNC missed versions from official npm registry.

@financial-times/dotcom-page-kit-cli

The Page Kit CLI provides a suite of actions to assemble modern Web projects. The CLI can be extended via plugins to provide additional functionality.

Getting started

This package is compatible with Node 12+ and is distributed on npm.

npm install --save-dev @financial-times/dotcom-page-kit-cli

Configuration is provided to the CLI by a page-kit.config.js file placed in your project root (next to package.json). Create this file now, including the fields defined below:

module.exports = {
  plugins: [],
  settings: {}
}

The plugins property is used to supply the plugins that should be loaded by the Page Kit CLI. These plugins should be installed in your project as development dependencies. Plugins by convention are namespaced with dotcom-build-.

The settings property is used to provide specific configuration for the individual CLI actions. These settings are covered below (see actions.)

To view the available actions and global options provided by the CLI, run the page-kit command with the --help flag:

page-kit --help

Actions

build

This action can be used to assemble the static assets for your application using Webpack. By default this action includes only a barebones Webpack configuration to bundle JavaScript source code but this can be extended via plugins to add additional functionality.

The action also creates a manifest.json (the file name is default but can be configured). It includes the hashed output names for the generated .js and .css chunks

Options

Entry points

The path for the entry point into your source code can be provided via the --entryFile CLI flag or via the configuration file. The default entry point is "src/index.js". Multiple entry points can only be defined using the configuration file. See the Webpack entry documentation for more information about entry points. The configuration file will take precedence over the CLI flag.

Usage via CLI flag:

page-kit build --entryFile ./path/to/entry.js

Usage via configuration file:

module.exports = {
  plugins: [...],
  settings: {
    build: {
      entry: {
        main: './path/to/entry.js'
      }
    }
  }
}
Output path

The generated output can be directed to a destination directory using the --outputPath CLI flag or via the configuration file. The default destination is "./dist". The configuration file will take precedence over the CLI flag.

Usage via CLI flag:

page-kit build --outputPath ./path/to/dist

Usage via configuration file:

module.exports = {
  plugins: [...],
  settings: {
    build: {
      outputPath: './path/to/dist'
    }
  }
}

Files will be created using the pattern [name].js in development mode and [name].[contenthash].js in production mode.

Manifest file name

The generated manifest file details the hashed output names for the emitted .js and .css chunks. The file name can be changed via the configuration file. The default file name is "manifest.json".

Usage via configuration file:

module.exports = {
  plugins: [...],
  settings: {
    build: {
      manifestFileName: 'asset-hashes.json'
    }
  }
}
Targets

A browserslist-compatible query that describes the environments you support / target for your project. It defaults to: last 2 Chrome versions, ie 11, Safari >= 9.1, ff ESR, last 2 Edge versions.

Usage via configuration file:

module.exports = {
  plugins: [...],
  settings: {
    build: {
      targets: {
        chrome: '58',
        ie: '11'
      }
    }
  }
}
Development and production modes

In production mode the generated output will be optimised, file names hashed, and full source maps, gzip and brotli compressed assets generated. Production mode is the default.

To enable development mode you can use the --development CLI flag. This will disable several optimisations in favour of providing faster builds and rebuilds. See the Webpack mode documentation for further information about modes.

page-kit build --development
Watch mode

For convenience the build action can watch source files and trigger a rebuild whenever they change. To enable watch mode use the --watch CLI flag.

page-kit build --watch

Hooks

This plugin exposes the following hooks as extension points. They are available as constants on the exported hooks object.

import { hooks } from '@financial-times/dotcom-page-kit-cli'

Please note: The hooks below are listed in the order they will be executed.

WEBPACK_CLEAN_PLUGIN_OPTIONS

Configuration options for the clean plugin.

WEBPACK_GZIP_COMPRESSION_PLUGIN_OPTIONS

Configuration options for the compression plugin set to use the gzip algorithm.

WEBPACK_BROTLI_COMPRESSION_PLUGIN_OPTIONS

Configuration options for the compression plugin set to use the Brotli algorithm.

WEBPACK_MANIFEST_PLUGIN_OPTIONS

Configuration options for the assets manifest plugin which provides the compilation entrypoints for each bundle by asset type e.g. scripts and styles.

BABEL_CONFIG

Configuration options for Babel.

BABEL_PRESET_ENV_OPTIONS

Configuration options for Babel Preset Env.

WEBPACK_JS_RULE

The Webpack rule for handling JavaScript files.

WEBPACK_CONFIG

The complete Webpack configuration object.

Current Tags

  • 0.6.3                                ...           latest (19 days ago)
  • 0.4.5                                ...           maintenance (3 months ago)

42 Versions

  • 0.6.3                                ...           19 days ago
  • 0.6.2                                ...           a month ago
  • 0.6.1                                ...           2 months ago
  • 0.6.0                                ...           2 months ago
  • 0.5.8                                ...           2 months ago
  • 0.5.7                                ...           2 months ago
  • 0.5.6                                ...           2 months ago
  • 0.5.5                                ...           3 months ago
  • 0.4.5                                ...           3 months ago
  • 0.5.4                                ...           3 months ago
  • 0.4.4                                ...           4 months ago
  • 0.5.3                                ...           4 months ago
  • 0.5.2                                ...           4 months ago
  • 0.4.3                                ...           4 months ago
  • 0.4.2                                ...           4 months ago
  • 0.5.1                                ...           4 months ago
  • 0.5.0                                ...           4 months ago
  • 0.5.0-beta.3                                ...           4 months ago
  • 0.5.0-beta.2                                ...           4 months ago
  • 0.5.0-beta.1                                ...           4 months ago
  • 0.4.1                                ...           4 months ago
  • 0.3.5                                ...           5 months ago
  • 0.3.4                                ...           5 months ago
  • 0.3.3                                ...           5 months ago
  • 0.3.2                                ...           5 months ago
  • 0.3.1                                ...           5 months ago
  • 0.3.0                                ...           5 months ago
  • 0.2.3                                ...           6 months ago
  • 0.2.2                                ...           6 months ago
  • 0.2.1                                ...           7 months ago
  • 0.2.0                                ...           7 months ago
  • 0.1.4                                ...           8 months ago
  • 0.1.3                                ...           8 months ago
  • 0.1.2                                ...           8 months ago
  • 0.1.1                                ...           8 months ago
  • 0.1.0                                ...           8 months ago
  • 0.0.4                                ...           9 months ago
  • 0.0.3                                ...           9 months ago
  • 0.0.2                                ...           9 months ago
  • 0.0.1                                ...           9 months ago
  • 0.0.1-test.2                                ...           9 months ago
  • 0.0.1-test.1                                ...           9 months ago

Copyright 2014 - 2017 © taobao.org |