-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
113 lines (106 loc) · 2.51 KB
/
build.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
const browserSync = require('browser-sync')
const Metalsmith = require('metalsmith')
const inplace = require('@metalsmith/in-place')
const fingerprint = require('metalsmith-fingerprint-ignore')
const layouts = require('@metalsmith/layouts')
const sass = require('@metalsmith/sass')
const sitemap = require('metalsmith-sitemap')
const robots = require('metalsmith-robots')
const watch = require('metalsmith-watch')
const permalinks = require('@metalsmith/permalinks')
const redirect = require('metalsmith-redirect')
const env = process.env.NODE_ENV || 'DEV'
console.log('Building for environment:', env)
const envOptions = {
DEV: {
site_url: 'http://localhost:8081',
watch: true,
trustmark: 'https://test-trust.profiles.eco',
noindex: true
},
TST: {
site_url: 'https://test.bigroom.eco',
watch: false,
trustmark: 'https://test-trust.profiles.eco',
noindex: true
},
PRD: {
site_url: 'https://bigroom.eco',
watch: false,
trustmark: 'https://trust.profiles.eco',
noindex: false
}
}
const options = envOptions[env]
console.log('Using options:', options)
const ms = Metalsmith(__dirname)
.metadata({
year: new Date().getFullYear(),
img_root: '/img',
site_url: options.site_url,
twitter_id: '@doteco',
livereload: options.watch,
noindex: options.noindex,
trustmark: options.trustmark
})
.source('./source')
.destination('./public/')
.clean(false)
.use(sass({
entries: {
'./scss/main.scss': 'css/main.css'
},
style: 'compressed',
sourceMap: true,
sourceMapContents: true
}))
.use(fingerprint({
pattern: 'css/main.css'
}))
.use(layouts({
default: 'default.njk',
pattern: '**/*.njk'
}))
.use(inplace({
engineOptions: {
cache: false
},
pattern: '**/*.njk'
}))
.use(permalinks({
relative: false
}))
.use(sitemap({
hostname: options.site_url,
omitIndex: true,
privateProperty: 'exclude'
}))
.use(robots({
sitemap: options.site_url + '/sitemap.xml'
}))
.use(redirect({
frontmatter: true,
noindex: false,
redirections: {
'/policies/': 'https://go.eco/policies/'
}
}))
ms.build(function (err, files) {
if (err) { throw err }
})
if (options.watch) {
ms.use(watch({
paths: {
/* eslint no-template-curly-in-string: 0 */
'${source}/**/*': true,
'scss/**/*': '{main.scss,**/*.njk}',
'layouts/**/*': '**/*.njk'
},
livereload: 35728
}))
browserSync.init({
port: 8081,
server: 'public',
watch: true
})
}