UNPKG

29.8 kBMarkdownView Raw
1# Configuration
2
3To use the Batfish CLI, your configuration file should be a Node module that exports a function returning a configuration object.
4
5```js
6module.exports = () => {
7 return { .. };
8};
9```
10
11(This format mirrors Webpack's configuration setup, which allows for unlimited flexibility and extensibility.)
12
13By default, the Batfish CLI looks for a `batfish.config.js` file in the current working directory.
14You can specify an alternate location.
15
16**Below, "project directory" means either**:
17
18- the directory of your configuration module, if one is provided; or
19- the current working directory, if no configuration module is provided.
20
21## Table of contents
22
23- [Basic options](#basic-options)
24 - [siteBasePath](#sitebasepath)
25 - [siteOrigin](#siteorigin)
26 - [publicAssetsPath](#publicassetspath)
27 - [applicationWrapperPath](#applicationwrapperpath)
28 - [stylesheets](#stylesheets)
29 - [browserslist](#browserslist)
30 - [devBrowserslist](#devbrowserslist)
31 - [pagesDirectory](#pagesdirectory)
32 - [outputDirectory](#outputdirectory)
33 - [temporaryDirectory](#temporarydirectory)
34- [Advanced options](#advanced-options)
35 - [dataSelectors](#dataselectors)
36 - [vendorModules](#vendormodules)
37 - [hijackLinks](#hijacklinks)
38 - [manageScrollRestoration](#managescrollrestoration)
39 - [spa](#spa)
40 - [webpackLoaders](#webpackloaders)
41 - [webpackPlugins](#webpackplugins)
42 - [webpackStaticStubReactComponent](#webpackstaticstubreactcomponent)
43 - [webpackStaticIgnore](#webpackstaticignore)
44 - [staticHtmlInlineDeferCss](#statichtmlinlinedefercss)
45 - [babelPlugins](#babelplugins)
46 - [babelPresets](#babelpresets)
47 - [babelPresetEnvOptions](#babelpresetenvoptions)
48 - [babelExclude](#babelexclude)
49 - [babelInclude](#babelinclude)
50 - [postcssPlugins](#postcssplugins)
51 - [fileLoaderExtensions](#fileloaderextensions)
52 - [jsxtremeMarkdownOptions](#jsxtrememarkdownoptions)
53 - [includePromisePolyfill](#includepromisepolyfill)
54 - [inlineJs](#inlinejs)
55 - [sitemap](#sitemap)
56 - [production](#production)
57 - [developmentDevtool](#developmentdevtool)
58 - [productionDevtool](#productiondevtool)
59 - [clearOutputDirectory](#clearoutputdirectory)
60 - [unprocessedPageFiles](#unprocessedpagefiles)
61 - [includePages](#includepages)
62 - [ignoreWithinPagesDirectory](#ignorewithinpagesdirectory)
63 - [webpackConfigClientTransform](#webpackconfigclienttransform)
64 - [webpackConfigStaticTransform](#webpackconfigstatictransform)
65 - [pageSpecificCss](#pagespecificcss)
66 - [port](#port)
67 - [verbose](#verbose)
68
69## Basic options
70
71### siteBasePath
72
73Type: `string`.
74Default: `'/'`.
75
76**You probably want to set this one.**
77
78Root-relative path to the base directory on the domain where the site will be deployed.
79Used by `prefixUrl` and `prefixUrl.absolute` (see ["Prefixing URLs"]).
80
81### siteOrigin
82
83Type: `string`.
84
85**You probably want to set this one.**
86
87Origin where the site will be deployed.
88
89*Required if you want to use `prefixUrl.absolute`* (see ["Prefixing URLs"]).
90
91Also, *required if you want a sitemap* (see [`sitemap`] option).
92
93### publicAssetsPath
94
95Type: `string`.
96Default: `'assets'`
97
98Default folder where batfish assets will be placed for static webpack build (aka `npm run build`)
99
100### applicationWrapperPath
101
102Type: `string`.
103
104Absolute path to a module exporting a React component that will wrap your React application.
105The component must be exported with `export default = YourWrapperComponent` or `module.exports = YourWrapperComponent`.
106
107This component will mount only once, wrapping Batfish's `Router` component, which in turn wraps your pages.
108
109### stylesheets
110
111Type: `Array<string>`.
112
113An array of **URLs, filenames, or globs** pointing to stylesheets that you want to include in your site.
114
115If an item is a URL, it must start with `http(s)` and must be publicly available, so Batfish can download it and work it into the CSS optimizations.
116If using filenames and globs, provide absolute paths.
117
118*If you need to control the order of your stylesheets, avoid globs.*
119Batfish cannot guarantee the order in which files matching your glob will be concatenated.
120
121`url()`s referenced in your stylesheets will be hashed and copied to Batfish's [`outputDirectory`].
122
123### browserslist
124
125Type: `Array<string>`.
126Default: `['> 5%', 'last 2 versions']`.
127
128A [Browserslist](https://github.com/ai/browserslist) value to specify which browsers you need to support.
129
130This option is used to process your CSS through [Autoprefixer] and determine which Babel transforms to apply through [babel-preset-env].
131
132**This option determines the browser support of your production build (`batfish build`).
133During development (`batfish start`), this will be overridden by [`devBrowserslist`]** (unless `devBrowserslist` is set to `false`).
134
135### devBrowserslist
136
137Type: `Array<string> | false`.
138Default: `['Edge >= 14', 'Firefox >= 52', 'Chrome >= 58', 'Safari >= 10', 'iOS >= 10.2'`].
139
140A [Browserslist](https://github.com/ai/browserslist) value to specify which browsers you need to support *with the development build* (`batfish start`).
141If this value is `false`, [`browserslist`] will be used for both production and development builds.
142
143This option is used to process your CSS through [Autoprefixer] and determine which Babel transforms to apply through [babel-preset-env].
144
145**This option determines the browser support of your development build only (`batfish start`).
146For production builds (`batfish build`), [`browserslist`] will be used**.
147
148You can also override this value from the CLI with the `--browsers` flag.
149If, for example, you spend *most* of your time developing in Chrome 60+, you can run `batfish start --browsers "Chrome >= 60"`, which would dramatically reduce the amount of transformation Babel performs.
150When you want to check all the browsers you support in production, you can run `batfish start --browsers false`.
151
152### pagesDirectory
153
154Type: `string`.
155Default: project directory + `src/pages/`.
156
157Absolute path to your project's directory of pages.
158
159### outputDirectory
160
161Type: `string`.
162Default: project directory + `_batfish_site/`.
163
164Absolute path to a directory where site files should be written.
165**You probably want to `.gitignore` this directory.**
166
167### temporaryDirectory
168
169Type: `string`.
170Default: project directory + `_batfish_tmp`.
171
172Absolute path to a directory where Batfish will write temporary files.
173It must be within the project directory.
174**You probably want to `.gitignore` this directory.**
175
176## Advanced options
177
178### dataSelectors
179
180Type: `{ [string]: (Object) => any }`.
181
182An object of selector functions for selecting processing data before it is injected into the page.
183Keys are selector names and values are functions that accept an object of build-time data and return a value that can be stringified into JSON.
184
185The object received as an argument contains the following properties:
186
187- `pages`: An array of objects for pages.
188 Each page object includes the following:
189 - `path`: The page's URL path.
190 - `filePath`: Absolute path to the page's file.
191 - `frontMatter`: Parsed front matter from the page's file.
192
193The return values of `dataSelectors` *must be stringifiable as JSON*.
194These values can be used in your components pages by `import`ing modules from `@mapbox/batfish/data/*`.
195See ["Injecting data"].
196
197### vendorModules
198
199Type: `Array<string>`.
200
201Identifiers of npm modules that you want to be added to the vendor bundle.
202The purpose of the vendor bundle is to deliberately group dependencies that change relatively infrequently — so this bundle will stay cached for longer than the others.
203
204### hijackLinks
205
206Type: `boolean`.
207Default `true`.
208
209By default, links are hijacked (with [link-hijacker]) and checked against your site's routes.
210If the link targets one of your routes, it will make a client-side change, instead of functioning as a regular link (with a regular page load).
211You can prevent this behavior by adding `data-batfish-no-hijack` to the link itself or to any of its descendents.
212
213If you want to disable this link hijacking altogether, handling it yourself, you can set this option to `false`.
214
215Use this option if you are having trouble with link hijacking or simply don't want it.
216If you have a single-page app that completely handles routing on its own (e.g. with React Router), you should set the [`spa`] option to `true`, which turns off link hijacking in addition to other things.
217
218### manageScrollRestoration
219
220Type: `boolean`.
221Default `true`.
222
223By default, restoration of scroll state during client-side browser navigation is managed by Batfish (with [scroll-restorer]).
224
225If you want to disable Batfish's scroll restoration altogether, handling it yourself or ignoring it, you can set this option to `false`.
226
227Use this option if you are having trouble with scroll restoration or simply don't want it.
228If you have a single-page app that completely handles routing and scroll management on its own (e.g. with React Router), you should set the [`spa`] option to `true`, which turns off scroll restoration in addition to other things.
229
230### spa
231
232Type: `boolean`.
233Default: `false`.
234
235**🚨 This option is DEPRECATED, please use [Underreact](https://github.com/mapbox/underreact/).**
236
237**Set this option to `true` if you do not need multiple Batfish pages, so do not need Batfish's router.**
238
239If `true`, your app is in SPA mode (single-page app): Batfish expects your app to have only one Batfish page, the landing page, and to handle routing on its own.
240The following things happen:
241
242- Link hijacking is disabled (the same as if you set the [`hijackLinks`] option to `false`).
243- Scroll restoration is disabled (the same as if you set the [`manageScrollRestoration`] option to `false`).
244- Batfish's `Router` is not rendered into your app, which lightens your bundle a little bit.
245- [Batfish modules](./batfish-modules.md) that rely on the router, like `routeTo` and `routeChangeListeners`, will not work.
246- The chunk for your landing page is bundled up with the main app chunk, instead of separated from it and loaded asynchronously.
247- Internal routing is automatically allowed on your landing page (the same as if you set the front matter `internalRouting: true`).
248 cf. ["Routing within a page"](./advanced-usage.md#routing-within-a-page).
249
250In SPA mode, you may be able to reduce your build time by using the [`webpackStaticIgnore`] option to reduce the quantity of modules that need to be parsed by Webpack during the build of static HTML files.
251For example, if there is loading spinner blocking much of the page until some data is fetched via HTTP, you could put all the content that will replace the spinner (after the data loads) in its own component, then ignore that component during the static build.
252That way, Webpack won't parse the component and all of its dependencies — which may even include *all* of your code, if that component includes your client-side router's route definitions and imports components for every route.
253
254To accomplish this, the component for your one page might look something like this:
255
256```jsx
257import React from 'react';
258import PageShell from '../component/page-shell';
259import Spinner from '../component/spinner';
260
261export default class HtmlPage extends React.Component {
262 constructor() {
263 super();
264 this.state = { App: null };
265 }
266
267 componentDidMount() {
268 // "eager" mode means that in the client-side bundling this import
269 // will not create a new async chunk: the code will be included in
270 // the main bundle, saving an HTTP request.
271 import(/* webpackMode: "eager" */ '../app').then(appModule => {
272 this.setState({ App: appModule.default });
273 });
274 }
275
276 render() {
277 const { App } = this.state;
278 const content = App ? <App /> : <Spinner />;
279 return <PageShell>{content}</PageShell>;
280 }
281}
282```
283
284And in your `batfish.config.js` file you'd use [`webpackStaticIgnore`] so the module at `'../app'` doesn't actually get parsed during the static HTML build:
285
286```js
287{ webpackStaticIgnore: [path.join(__dirname, './src/app')] }
288```
289
290### webpackLoaders
291
292Type: `Array<Object>`.
293
294Additional loader configuration to pass to Webpack during both Webpack builds (client bundling and HTML generating).
295Each object should be a [Webpack Rule](https://webpack.js.org/configuration/module/#rule).
296
297**Warning:** You may need remove the extensions for files your new loader(s) handles from [`fileLoaderExtensions`](#fileloaderextensions).
298
299### webpackPlugins
300
301Type: `Array<Object>`.
302
303Additional plugin configuration to pass to Webpack. These plugins will be included in both the client bundling task and the static HTML rendering task.
304
305For plugins exposed on the `webpack` module itself (e.g. `webpack.DefinePlugin`), **you should use Batfish's version of Webpack instead of installing your own.**
306That will prevent any version incompatibilities.
307**The Batfish package exposes its version of Webpack as the `webpack` property of its export.**
308
309Here, for example, is how you could use the `DefinePlugin` in your `batfish.config.js`:
310
311```js
312const batfish = require('@mapbox/batfish');
313
314module.exports = () => {
315 return {
316 webpackPlugins: new batfish.webpack.DefinePlugin(..)
317 };
318}
319```
320
321### webpackStaticStubReactComponent
322
323Type: `Array<string>`.
324
325An array of absolute paths to React component modules that you would like to stub during the static Webpack build.
326When these files are `import`ed, what you'll get is a simple React component that renders `null`:
327
328```js
329module.exports = function StubbedComponent() {
330 return null;
331};
332```
333
334You might want to use this if you are working on a simple app and don't care at all how it initially renders — i.e. a create-react-app-style app where the static HTML that is served contains no content, just waits for the JS to download and execute.
335
336Depending on how you use this option, you may need to set [`staticHtmlInlineDeferCss`] to `false` to avoid a flash of unstyled content.
337
338For more information about the options for this use case, see ["Minimal builds for single-page apps"].
339
340### webpackStaticIgnore
341
342Type: [Webpack `Condition`].
343
344Any modules matching this description will be ignored (with the [ignore-loader](https://github.com/cherrry/ignore-loader)) during the static Webpack build.
345**Any dependencies that cannot execute in Node (e.g. because they reference `window` or `document`) should be targeted by this option.**
346You may need to other precautions, as well.
347But most of the time, this will help you use browser-only libraries without breaking your static build.
348
349### staticHtmlInlineDeferCss
350
351Type: `boolean`.
352Default: `true`.
353
354By default, Batfish reads your rendered HTML pages, inlines the CSS that they need, and defers loading the rest of your CSS until after the `DOMContentLoaded` event, so it does not block page rendering.
355
356Usually, this is exactly what you want, giving your users the fastest possible initial render.
357However, if you've used [`webpackStaticStubReactComponent`], [`webpackStaticIgnore`], or other means to reduce the amount of HTML that gets generated — so your static HTML does not in fact include all that you need for the page's initial rendering (see ["Minimal builds for single-page apps"])— then the CSS inlined on that HTML page will *not* cover all of its needs.
358When the JS downloads and executes and your actual app gets rendered, you might have a flash of unstyled content lasting until the complete CSS (whose loading was deferred) finishes downloading.
359
360To get around this, you can turn off Batfish's optimization by setting `staticHtmlInlineDeferCss: false`.
361Batfish will not inline CSS into your HTML pages (which also speeds up your build), and will not defer the loading of your full stylesheet.
362Instead, the full stylesheet will be added as a `<link>` to the HTML's `<head>`.
363
364### babelPlugins
365
366Type: `Array<string>`. Default: `[]`.
367
368Additional plugins to pass to Babel during both Webpack builds (client bundling and HTML generating).
369**You should `require.resolve()` your plugins.**
370Otherwise, Babel might end up looking in the wrong place for the npm package.
371
372*(The prior recommendation to `require` plugins is deprecated. Instead of `require`ing plugins you should `require.resolve` them.)*
373
374For example:
375
376```js
377{ babelPlugins: [require.resolve('babel-plugin-transform-fancy-syntax')] }
378```
379
380Plugins you provide are concatenated to the following default plugins:
381
382- Always
383 - [babel-plugin-syntax-dynamic-import](https://babeljs.io/docs/plugins/syntax-dynamic-import/)
384 - [babel-plugin-transform-class-properties](https://babeljs.io/docs/plugins/transform-class-properties/)
385 - [babel-plugin-transform-object-rest-spread](https://babeljs.io/docs/plugins/transform-object-rest-spread/)
386 - [@mapbox/babel-plugin-transform-jsxtreme-markdown](https://github.com/mapbox/jsxtreme-markdown/tree/master/packages/babel-plugin-transform-jsxtreme-markdown): See [`jsxtremeMarkdownOptions`].
387- Development only
388 - [babel-plugin-transform-react-jsx-source](https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-react-jsx-source)
389 - [babel-plugin-transform-react-jsx-self](https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-react-jsx-self)
390- Production only
391 - [babel-plugin-transform-react-remove-prop-types](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types)
392
393### babelPresets
394
395Type: `Array<string>`. Default: `[]`.
396
397Additional presets to pass to Babel during both Webpack builds (client bundling and HTML generating).
398**You should `require.resolve()` your presets.**
399Otherwise, Babel might end up looking in the wrong place for the npm package.
400
401*(The prior recommendation to `require` presets is deprecated. Instead of `require`ing presets you should `require.resolve` them.)*
402
403For example:
404
405```js
406{ babelPresets: [require.resolve('babel-preset-magic')] }
407```
408
409The two presets [babel-preset-react] and [babel-preset-env] are automatically applied.
410You can pass options to [babel-preset-env] with the option [`babelPresetEnvOptions`].
411
412### babelPresetEnvOptions
413
414Type: `Object`. [Options for babel-preset-env].
415
416[babel-preset-env] is always used.
417By default, it receives the following options:
418
419- `useBuiltIns` is `true`.
420- `target.browsers` is your [`browserslist`] or [`devBrowserslist`] value (read more about those options to understand when each is used).
421- `modules` is `false`.
422
423Use this option to further customize your build by passing any of the other many [options for babel-preset-env](https://babeljs.io/docs/plugins/preset-env/#options).
424It your object will be merged with the defaults — so they will only be overridden if you deliberately do so.
425
426### babelExclude
427
428Type: [Webpack `Condition`].
429Default: `/[/\\\\]node_modules[/\\\\]/`. (A nasty regular expression that excludes all nested `node_modules`.)
430
431By default, all packages installed by npm are excluded from Babel compilation (see [`babelExclude`]).
432If you'd like to change that (e.g. to exclude more files), provide a valid [Webpack `Condition`].
433
434Make sure your condition somehow excludes the majority of `node_modules` from compilation, or your builds could slow down dramatically.
435
436### babelInclude
437
438Type: `Array<string | Condition>`.
439Default: `[]`.
440
441By default, all packages installed by npm are excluded from Babel compilation (see [`babelExclude`]).
442If, however, you use a library that includes ES2015+ but does not get compiled for publication (e.g. any of the [promise-fun](https://github.com/sindresorhus/promise-fun) modules), then you'll need to pass that module through Babel.
443That's what this option is for.
444
445The easiest way to include an npm package in your compilation is to pass its name as a string.
446
447But if you have more complex needs, any valid [Webpack `Condition`] will work here.
448All conditions will be combined with `test: /\.jsx$/` so only `.js` or `.jsx` files are compiled.
449
450Some examples:
451
452To compile `p-queue`:
453
454```js
455[`p-queue`]
456```
457
458To compile both `p-queue` and `@mapbox/mapbox-gl-style-spec` *except for* its `dist/` directory and any nested `node_modules`:
459
460```js
461[
462 'p-queue',
463 {
464 include: path.resolve(__dirname, 'node_modules/@mapbox/mapbox-gl-style-spec'),
465 exclude: [
466 path.resolve(
467 __dirname,
468 'node_modules/@mapbox/mapbox-gl-style-spec/dist'
469 ),
470 path.resolve(
471 __dirname,
472 'node_modules/@mapbox/mapbox-gl-style-spec/node_modules'
473 )
474 ]
475 }
476]
477```
478
479### postcssPlugins
480
481Type: `Array<Function> | Function`.
482Default: [Autoprefixer].
483
484All of the CSS you load via [`stylesheets`] is run through [PostCSS](http://postcss.org/), so you can apply any [PostCSS plugins](https://github.com/postcss/postcss/blob/master/docs/plugins.md) to it.
485By default, only [Autoprefixer] is applied.
486
487If a function is provided, it will receive the default array as an argument and should return a new array.
488A transform function is probably preferable if you only need to add or remove an item or two from the default array.
489
490### fileLoaderExtensions
491
492Type: `Array<string> | Function`.
493Default: `['jpeg', 'jpg', 'png', 'gif', 'webp', 'mp4', 'webm', 'woff', 'woff2']`.
494
495An array of extensions for files that you would like to Webpack's [file-loader](https://github.com/webpack-contrib/file-loader).
496
497If a function is provided, it will receive the default array as an argument and should return a new array.
498A transform function is probably preferable if you only need to add or remove an item or two from the default array.
499
500### jsxtremeMarkdownOptions
501
502Type: `Object`.
503
504Markdown pages are passed through [jsxtreme-markdown-loader](https://github.com/mapbox/jsxtreme-markdown-loader), which runs the Markdown through [`jsxtremeMarkdown.toComponentModule`].
505This option is passed directly to [`jsxtremeMarkdown.toComponentModule`].
506
507Please read the documentation for [`jsxtremeMarkdown.toComponentModule`'s `options`](https://github.com/mapbox/jsxtreme-markdown#options-1) for complete details.
508But here are some of the options you are more likely to want to use with Batfish:
509
510- `remarkPlugins` and `rehypePlugins` allow you provide [remark](https://github.com/wooorm/remark) and [rehype](https://github.com/wooorm/rehype) plugins, which get applied as your Markdown is converted to a React component.
511 There are a wide variety of plugins, from header slug insertions to Markdown syntax extensions to code block syntax highlighting and so on.
512- `prependJs` allows you to prepend JS to *every* Markdown page in your site.
513 For example, if you have a utility function that you want to make available to every Markdown page, you can use this option to `import` it.
514
515### includePromisePolyfill
516
517Type: `boolean`.
518Default: `true`.
519
520Webpack and Batfish both rely on Promises, so if you want to support IE11 you'll need a Promise polyfill.
521
522By default, [es6-promise](https://github.com/stefanpenner/es6-promise)'s auto-polyfill is inserted at the beginning of the vendor bundle.
523**If you'd like to use your own Promise polyfill, you should set this option to `false`** (e.g. if [core-js](https://github.com/zloirock/core-js) is throwing in polyfills via some Babel tool or other).
524
525### inlineJs
526
527Type: `Array<Object>`.
528
529If you want to inline JS into static HTML before the Webpack bundle, this is the best way to do it.
530
531On the development server, they will be added at the beginning of the Webpack bundle for debugging (sourcemaps should be available).
532For the static build, they will be injected directly into the `<head>`.
533
534Each item is an object with the following properties:
535
536- **filename** (`string`): Path to the JS file.
537- **uglify** (`boolean`, default `true`): Whether or not to process the file with [UglifyJs] before inserting into the `<head>` during the static build.
538
539### sitemap
540
541Type: `boolean`.
542Default: `true`.
543
544By default, if you have set [`siteOrigin`] a `sitemap.xml` file will be generated and placed in your [`outputDirectory`] during `batfish build`.
545Set this to `false` to skip this step if you do not want a sitemap.
546
547### production
548
549Type: `boolean`.
550Default: `false` for `start`, `true` for `build`.
551
552Whether or not to build for production (e.g. minimize files, trim React).
553
554### developmentDevtool
555
556Type: `string | false`.
557Default: `'cheap-module-source-map'`.
558
559A [Webpack devtool value](https://webpack.js.org/configuration/devtool/#devtool).
560The Webpack docs explain the benefits and drawbacks of each.
561
562### productionDevtool
563
564Type: `string | false`.
565Default: `false`.
566
567A [Webpack devtool value](https://webpack.js.org/configuration/devtool/#devtool).
568The Webpack docs explain the benefits and drawbacks of each.
569
570### clearOutputDirectory
571
572Type: `boolean`.
573Default: `true`.
574
575By default, the [`outputDirectory`] will be cleared before `start` and `build` execute.
576Set this to `false` to leave the [`outputDirectory`] as it is and only add files to it.
577
578### unprocessedPageFiles
579
580Type: `Array<string>`.
581
582An array of globs **relative to the [`pagesDirectory`]**.
583
584By default, all `.js` and `.md` files within the [`pagesDirectory`] are processed as pages, producing HTML files at their paths.
585If you would like instead to copy `.js` or `.md` files as static files, without creating corresponding HTML files, use this option.
586
587For example, if you have a `scripts/` directory and all the `.js` files within it are *not* pages, but are static JavaScript files that you want to expose at `/scripts/*.js` URLs, you could set `unprocessedPageFiles` to `['scripts/**/*.js']`.
588
589### includePages
590
591Type: `Array<string>`.
592
593A whitelist flag which takes an array of globs indicating the pages of your site you want to build. Note, if left empty it will include all pages.
594
595You can use this option during development to speed up your builds by only building the specified pages.
596Fewer files will be fed into Webpack, which means the build will go faster.
597
598This is the option that `batfish start --include` manipulates; typically, you'll interface with this option that way, instead of setting it directly in your configuration.
599
600**You should only use this option during development.**
601
602### ignoreWithinPagesDirectory
603
604Type: `Array<string>`.
605
606An array of globs **relative to the [`pagesDirectory`]**.
607
608By default, all files within the [`pagesDirectory`] that are *not* `.js` and `.md` files are copied to corresponding paths in the [`outputDirectory`].
609(See ["Non-page files within the pages directory"] for why you might use this feature.)
610Sometimes, however, you want to colocate files with your pages and *do not* want those files to be copied into the [`outputDirectory`], because you don't want them to available at public URLs when you deploy your site.
611
612This option allows you to provide globs specifying files in the [`pagesDirectory`] that should *not* be copied.
613
614For example, if you have HTML files in your [`pagesDirectory`] that your JS pages will import with [Webpack's raw-loader], you could prevent them from being copied to the [`outputDirectory`] with `ignoreWithinPagesDirectory: ['**/*.html']`.
615
616### webpackConfigClientTransform
617
618Type: `Function`.
619
620The Webpack config for client-side bundles will be passed through this function before it's used.
621**Only use this option if you know what you're doing!**
622You need to be careful not to change configuration that Batfish relies on.
623
624### webpackConfigStaticTransform
625
626Type: `Function`.
627
628The Webpack config for static, server-side bundling will be passed through this function before it's used.
629**Only use this option if you know what you're doing!**
630You need to be careful not to change configuration that Batfish relies on.
631
632### pageSpecificCss
633
634Type: `boolean`.
635Default:`true`.
636
637Set to `false` to disable Batfish's minimal loader for compiling `.css` with PostCSS and transforming them into React components that you can render as needed.
638Read more in ["Page-specific CSS"].
639
640Turning this off will allow you to use different Webpack loaders for `.css` files — whatever suits your preferences.
641
642### port
643
644Type: `number`.
645Default: `8080`.
646
647Preferred port for development servers.
648If the specified port is unavailable, another port is used.
649
650### verbose
651
652Type: `boolean`.
653Default: `false`.
654
655If `true`, more information will be logged to the console.
656
657[uglifyjs]: https://github.com/mishoo/UglifyJS2
658
659[autoprefixer]: https://github.com/postcss/autoprefixer
660
661["prefixing urls"]: ../README.md#prefixing-urls
662
663[`outputdirectory`]: #outputdirectory
664
665[`pagesdirectory`]: #pagesdirectory
666
667[`stylesheets`]: #stylesheets
668
669[`babelexclude`]: #babelexclude
670
671[`spa`]: #spa
672
673[`hijacklinks`]: #hijacklinks
674
675[`managescrollrestoration`]: #managescrollrestoration
676
677[`jsxtrememarkdownoptions`]: #jsxtrememarkdownoptions
678
679["injecting data"]: ./advanced-usage.md#injecting-data
680
681["page-specific css"]: ./advanced-usage.md#page-specific-css
682
683[`jsxtrememarkdown.tocomponentmodule`]: https://github.com/mapbox/jsxtreme-markdown#tocomponentmodule
684
685[link-hijacker]: https://github.com/mapbox/link-hijacker
686
687[webpack `condition`]: https://webpack.js.org/configuration/module/#condition
688
689[babel-preset-react]: https://babeljs.io/docs/plugins/preset-react/
690
691[babel-preset-env]: https://babeljs.io/docs/plugins/preset-env/
692
693[`babelpresetenvoptions`]: #babelpresetenvoptions
694
695[options for babel-preset-env]: https://babeljs.io/docs/plugins/preset-env/#options
696
697["non-page files within the pages directory"]: ../README.md#non-page-files-within-the-pages-directory
698
699[webpack's raw-loader]: https://github.com/webpack-contrib/raw-loader
700
701[scroll-restorer]: https://github.com/mapbox/scroll-restorer
702
703[`webpackstaticignore`]: #webpackstaticignore
704
705[`webpackstaticstubreactcomponent`]: #webpackstaticstubreactcomponent
706
707[`statichtmlinlinedefercss`]: #statichtmlinlinedefercss
708
709[`devbrowserslist`]: #devbrowserslist
710
711[`browserslist`]: #browserslist
712
713[`siteorigin`]: #siteorigin
714
715[`sitemap`]: #sitemap
716
717["minimal builds for single-page apps"]: ./advanced-usage.md#minimal-builds-for-single-page-apps