-
Notifications
You must be signed in to change notification settings - Fork 46
/
.boltrc.js
89 lines (83 loc) · 2.4 KB
/
.boltrc.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
/**
* Demo for testing out Bolt config updates that fall back to
* using https://github.com/davidtheclark/cosmiconfig if a .boltrc
* config file isn't already specified or initialized.
*
* This means that a .boltrc config in a parent folder would
* automatically get used if a more local one can't be found --
*
* For example, we can now use Webpack's vanilla CLI as-is!
*
* ```bash
* cd packages/build-tools
* npx webpack-cli --config="create-webpack-config.js" --progress
* ```
*/
const path = require('path');
const globby = require('globby');
const baseBoltDir = path.join(__dirname, './docs-site');
const siteConfig = require(path.join(baseBoltDir, '.boltrc'));
const resolve = require('resolve');
// Paths that are relative to `baseBoltDir` must now be relative to this directory (i.e. `__dirname`)
const adjustRelativePath = thePath =>
path.relative(__dirname, path.resolve(baseBoltDir, thePath));
// Gather directories for any/all image fixtures and consolidate for the image resizing task
const imageFixtureDirs = globby
.sync(
path.join(
__dirname,
'./packages/components/**/fixtures/**/*.{jpg,jpeg,png,svg}',
),
)
.map(file => path.dirname(file));
const imageSets = [];
imageFixtureDirs.forEach(fixturePath => {
imageSets.push({
base: fixturePath,
glob: '*.{jpg,jpeg,png,svg}',
dist: path.join(adjustRelativePath(siteConfig.wwwDir), 'fixtures'),
});
});
const nonImageFixtures = globby.sync([
'./packages/components/**/fixtures/**/*',
'!./packages/components/**/fixtures/**/*.{jpg,jpeg,png}',
'./packages/components/**/fixtures/videos/**/*',
]);
const itemsToCopy = [];
nonImageFixtures.forEach(fixturePath => {
itemsToCopy.push({
from: path.join(__dirname, fixturePath),
to: path.join(
__dirname,
adjustRelativePath(siteConfig.wwwDir),
'fixtures/videos',
),
flatten: true,
});
});
module.exports = {
wwwDir: adjustRelativePath(siteConfig.wwwDir),
buildDir: adjustRelativePath(siteConfig.buildDir),
iconDir: [],
components: {
global: [
...siteConfig.components.global,
],
},
images: {
sets: imageSets,
},
prod: true,
sourceMaps: false,
enableCache: true,
verbosity: 1,
copy: [...itemsToCopy],
alterTwigEnv: [
{
file: `${path.dirname(
resolve.sync('@bolt/twig-renderer/package.json'),
)}/SetupTwigRenderer.php`,
functions: ['addBoltCoreExtensions'],
},
],
};