-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
99 lines (93 loc) · 2.49 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
var Metalsmith = require('metalsmith'),
each = require('metalsmith-each'),
templates = require('metalsmith-templates'),
collections = require('metalsmith-collections'),
lunr = require('metalsmith-lunr'),
less = require('metalsmith-less'),
watch = require('metalsmith-watch'),
serve = require('metalsmith-serve')
assets = require('metalsmith-assets'),
concat = require('metalsmith-concat'),
helpers = require('./tools/helpers'),
cleanUrls = helpers.cleanUrls,
fixResources = helpers.fixRelativeResources,
crumbs = helpers.crumbs,
path = require('path'),
swig = require('swig'),
isDev = (process.argv.length === 3 && process.argv[2] === 'dev');
/* Swig Options */
swig.setDefaults({
loader: swig.loaders.fs(__dirname + '/layouts'),
varControls: ['{%=', '%}'],
locals: { baseUrl: isDev ? '//localhost:8000' : '//thedustinsmith.com/metalsmith-test' }
});
var swigOpts = {
engine: 'swig'
};
var swigInPlace = {
engine: 'swig',
inPlace: true
};
/* End Swig Opts */
/* Editor Compiled */
var editorJs = {
files: [
'bower_components/zeroclipboard/dist/ZeroClipboard.min.js',
'bower_components/mustache/mustache.min.js',
'bower_components/opentip/downloads/opentip-native.js',
'bower_components/wysihtml/dist/wysihtml5x-toolbar.min.js',
'bower_components/wysihtml/parser_rules/advanced_and_extended.js',
'js/editor/dialogs.js',
'js/editor/filereader.js',
'js/editor/editor.fileuploader.js',
'js/editor/editor.sizer.js',
'js/editor/editor.links.js'
],
output: 'js/editor.compiled.js'
};
var editorCss = {
files: [
'bower_components/opentip/css/opentip.css',
'css/editor.css'
],
output: 'css/editor.compiled.css'
};
/* End Editor Compiled */
var ms = Metalsmith(__dirname)
.use(cleanUrls())
.use(collections({
stuff: { refer: false }
}))
.use(crumbs())
.use(each(function (file, name) {
// This serves to help swig with template inheritance
file.filename = name;
}))
.use(templates(swigInPlace))
.use(templates(swigOpts))
.use(fixResources({
relRoot: (isDev) ? '' : 'metalsmith-test/'
}))
.use(less({
pattern: '**/{all,editor}.less',
useDefaultSourceMap: true
}))
.use(assets({
source: './bower_components',
destination: './bower_components'
}))
.use(concat(editorJs))
.use(concat(editorCss))
.use(lunr())
.destination('./build');
if (isDev) {
ms
.use(watch("**/*.*"))
.use(serve({
port: 8000,
verbose: true
}));
}
ms.build(function (err, files) {
if(err) throw err;
});