-
Notifications
You must be signed in to change notification settings - Fork 1
/
metalsmith.js
87 lines (83 loc) · 2.18 KB
/
metalsmith.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
import { dirname } from 'path';
import { fileURLToPath } from 'url';
import markdown from "@metalsmith/markdown";
import registerHelpers from "metalsmith-register-helpers";
import permalinks from "@metalsmith/permalinks";
import layouts from "@metalsmith/layouts";
import browserify from "metalsmith-browserify-alt";
import stylus from "metalsmith-stylus";
import browserSync from "metalsmith-browser-sync";
import htmlMinify from "metalsmith-html-minifier";
import discoverPartials from 'metalsmith-discover-partials';
import filenames from "metalsmith-filenames";
import nib from "nib";
// custom plugins
import mdLeftNav from "./plugins/md-left-nav.js";
import ghContributors from "./plugins/gh-contributors.js";
const __dirname = dirname(fileURLToPath(import.meta.url));
import metalsmith from "metalsmith";
var ms = metalsmith(__dirname)
.source("./content")
.destination("./build")
.clean(true)
.use((files, metalsmith, done) => {
metalsmith.metadata({
name: "PLOP",
title: "Consistency Made Simple",
production: process.env.NODE_ENV === "production",
});
setImmediate(done);
})
.use(ghContributors())
.use(markdown())
.use(mdLeftNav())
.use(permalinks({ relative: false }))
.use(registerHelpers())
.use(discoverPartials({
directory: 'partials',
pattern: /\.hbs$/
}))
.use(filenames())
.use(layouts())
.use(htmlMinify())
.use(
stylus({
compress: true,
sourcemap: process.env.NODE_ENV !== "production",
paths: ["./styles"],
use: [nib()],
})
)
.use(
browserify({
defaults: {
cache: {},
packageCache: {},
transform: ["uglifyify"],
plugin: process.env.NODE_ENV !== "production" ? ["watchify"] : [],
debug: process.env.NODE_ENV !== "production",
},
})
);
if (process.env.NODE_ENV !== "production") {
ms = ms.use(
browserSync({
ui: false,
files: [
"content/**",
"styles/**",
"scripts/**",
"layouts/**",
"partials/**",
"helpers/**",
],
server: "build",
port: 5000,
ghostMode: false,
open: false,
})
);
}
ms.build(function (err) {
if (err) throw err;
});