forked from manson413/mapbox-gl-js-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
batfish.config.js
108 lines (105 loc) · 4.15 KB
/
batfish.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
const webpack = require('webpack');
const mapboxAssembly = require('@mapbox/mbx-assembly');
const path = require('path');
const apiNavigation = require('./docs/data/api-navigation');
const { buildApiSearch } = require('./docs/util/build-api-search');
module.exports = () => {
const config = {
siteBasePath: '/mapbox-gl-js',
siteOrigin: 'https://docs.mapbox.com',
pagesDirectory: `${__dirname}/docs/pages`,
outputDirectory: path.join(__dirname, '_site'),
browserslist: mapboxAssembly.browsersList,
postcssPlugins: mapboxAssembly.postcssPipeline.plugins,
productionDevtool: 'source-map',
stylesheets: [
require.resolve('@mapbox/mbx-assembly/dist/assembly.css'),
require.resolve('@mapbox/dr-ui/css/docs-prose.css'),
`${__dirname}/docs/components/site.css`,
require.resolve('@mapbox/dr-ui/css/prism.css'),
`${__dirname}/vendor/docs-page-shell/page-shell-styles.css`
],
applicationWrapperPath: `${__dirname}/docs/components/application-wrapper.js`,
webpackLoaders: [
// Use raw loader to get the HTML string contents of examples
{
test: /\.html$/,
use: 'raw-loader'
}
],
ignoreWithinPagesDirectory: ['example/*.html'],
webpackPlugins: [
// Make environment variables available within JS that Webpack compiles.
new webpack.DefinePlugin({
// DEPLOY_ENV is used in config to pick between local/production.
'process.env.DEPLOY_ENV': `"${process.env.DEPLOY_ENV}"`
})
],
inlineJs: [
{
filename: `${__dirname}/vendor/docs-page-shell/page-shell-script.js`
}
],
jsxtremeMarkdownOptions: {
getWrapper: () => {
return path.join(
__dirname,
'./docs/components/markdown-page-shell.js'
);
},
rehypePlugins: [
require('rehype-slug'),
require('@mapbox/rehype-prism'),
require('@mapbox/dr-ui/plugins/add-links-to-headings'),
require('@mapbox/dr-ui/plugins/create-sections'),
require('@mapbox/dr-ui/plugins/make-table-scroll')
]
},
dataSelectors: {
apiSearch: () => buildApiSearch(),
examples: ({ pages }) => {
return pages
.filter(
({ path, frontMatter }) =>
/\/example\//.test(path) && frontMatter.tags
)
.map(example => {
return {
path: example.path,
title: example.frontMatter.title,
description: example.frontMatter.description,
tags: example.frontMatter.tags,
pathname: example.frontMatter.pathname
};
});
},
listSubfolders: data => {
const folders = data.pages
.filter(file => {
return file.path.split('/').length === 4;
})
.map(folder => {
return folder;
});
return folders;
},
apiNavigation: () => {
return apiNavigation;
}
},
devBrowserslist: false,
babelInclude: [
'documentation',
'@mapbox/mapbox-gl-style-spec',
'fuse.js'
],
webpackStaticIgnore: [/util\/util\.js$/]
};
// Local builds treat the `dist` directory as static assets, allowing you to test examples against the
// local branch build. Non-local builds ignore the `dist` directory, and examples load assets from the CDN.
config.unprocessedPageFiles = ['**/dist/**/*.*'];
if (process.env.DEPLOY_ENV !== 'local') {
config.ignoreWithinPagesDirectory.push('**/dist/**/*.*');
}
return config;
};