This package exports a Webpack plugin to configure it with the ability to build JavaScript that makes use of features that are specific to ft.com.
This module is compatible with Node 12+ and is distributed on npm.
npm install --save-dev @financial-times/dotcom-build-js
After installing the module you must add it to the list of plugins in your project's webpack.config.js
configuration file:
+ const { PageKitJsPlugin } = require('@financial-times/dotcom-build-js')
module.exports = {
plugins: [
+ new PageKitJsPlugin(options)
]
}
This plugin configures Babel to compile JavaScript syntax and features that aren't supported by every browser into JavaScript that is. The browsers we target are:
- the latest version of Chrome
- the lastest version of Edge
- Safari 9.1
- Firefox Extended Support Release
As well as features in current JavaScript standards, we also compile these non-standard features:
dotcom-build-js
can be configured with options. Other methods of configuring Babel are not supported by Page Kit, because it's possible to produce output that doesn't work in the browsers we support, or to hurt performance by producing inconsistent output between apps, reducing caching effectiveness.
Option | Type | Default | Description |
---|---|---|---|
jsxPragma |
String | "h" |
See https://babeljs.io/docs/en/babel-preset-react#pragma |
jsxPragmaFrag |
String | "Fragment" |
See https://babeljs.io/docs/en/babel-preset-react#pragmafrag |