-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·164 lines (161 loc) · 3.96 KB
/
index.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
const Metalsmith = require('metalsmith');
const cleancss = require('metalsmith-clean-css');
const collection = require('metalsmith-collections');
const concat = require('metalsmith-concat');
const dateFormat = require('metalsmith-date-formatter');
const drafts = require('metalsmith-drafts');
const feed = require('metalsmith-feed');
const ignore = require('metalsmith-ignore');
const templates = require('metalsmith-layouts');
const markdown = require('metalsmith-markdown');
const move = require('metalsmith-movey').default;
const partials = require('metalsmith-discover-partials');
const permalinks = require('metalsmith-permalinks');
const postcss = require('metalsmith-postcss');
const metadata = require('metalsmith-writemetadata');
const handlebars = require('handlebars');
const uglifyjs = require("metalsmith-uglifyjs");
Metalsmith(__dirname)
.metadata({
site: {
title: "Grow Digital",
description: "Web design, workshops, freelance",
url: "https://www.growdigital.org/",
author: "Jake Rayson"
}
})
.source("./src")
.destination("./build")
// Only clean in dev. Set to false to preserve Fractal styleguide.
.clean(true)
// Ignoring documentation and Fractal templates
.use(
ignore([
"docs/*",
"assets/modules/**/**/*.hbs",
"assets/modules/**/**/**/*.hbs",
"assets/modules/**/**/**/**/*.hbs"
])
)
// Concatenation: the order is important
// Concat CSS
.use(
concat({
files: [
"assets/css/settings/variables.css",
"normalize.css/normalize.css",
"assets/css/settings/base.css",
"assets/css/settings/typography.css",
"assets/css/settings/responsive.css",
"assets/modules/objects/**/*.css",
"assets/modules/components/**/**/*.css",
"assets/modules/utilities/**/**/*.css",
"assets/css/shame.css"
],
searchPaths: ["node_modules"],
output: "assets/styles.css"
})
)
// Optimise (uglify) CSS
.use(
cleancss({
files: "assets/styles.css"
})
)
// Concatenate JavaScript
.use(
concat({
files: [
"assets/js/*.js",
"assets/modules/objects/**/*.js",
"assets/modules/components/**/**/*.js",
"assets/modules/utilities/**/**/*.js"
],
searchPaths: ["node_modules"],
output: "assets/scripts.js"
})
)
// Optimise (uglify) JavaScript
.use(
uglifyjs({
src: ["assets/scripts.js"],
override: true,
uglifyOptions: {
mangle: true,
compress: {
unused: false,
warnings: true
}
}
})
)
// +1 PostCSS. Use CSS preprocessor of your choice if you’d rather!
.use(
postcss({
plugins: {
"postcss-cssnext": {}
}
})
)
.use(drafts())
.use(
collection({
post: {
pattern: "posts/**/*.md",
sortBy: "date",
reverse: true
}
})
)
// To help with debugging, use metadata
// .use(metadata({
// pattern: ['*.md', '*.html']
// }))
// Use GitFriendlyMarkdown formatter
.use(
markdown({
gfm: true
})
)
// Change your date format here
// Uses Moment.js http://momentjs.com/docs/#/displaying/
.use(
dateFormat({
key: "date",
format: "ddd D MMM YYYY"
})
)
.use(
permalinks({
pattern: "./posts/:title",
relative: false
})
)
// I like Handlebars templating. You can use what you like.
.use(
templates({
engine: "handlebars",
partials: "partials"
})
)
// Create RSS feed
.use(
feed({
collection: "post",
postDescription: function(file) {
return file.excerpt;
}
})
)
// Move graphics assets out of modules and into /assets/images/ directory
.use(
move({
"assets/modules/components/**/**/*.+(png|svg|ico|jpg)":
"assets/images/{name}{ext}"
})
)
.build(function(err, files) {
if (err) {
throw err;
}
});