-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathBrocfile.ts
60 lines (50 loc) · 1.55 KB
/
Brocfile.ts
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
import { BrocfileOptions } from 'broccoli';
import md from './lib/plugin/markdown-handlebars';
import merge from 'broccoli-merge-trees';
import broccoliSass from 'broccoli-sass-source-maps';
import sass from 'sass';
import sassLint from 'broccoli-sass-lint';
import funnel from 'broccoli-funnel';
import assetRev from 'broccoli-asset-rev';
import LiveReload from 'broccoli-livereload';
import CleanCss from 'broccoli-clean-css';
import menu from './menu';
const compileSass = broccoliSass(sass);
// noinspection JSUnusedGlobalSymbols
export default (options: BrocfileOptions) => {
const appRoot = 'src';
const isProduction = options.env === 'production';
const markdown = md(`${appRoot}/content`, `${appRoot}/templates`, {
data: {
title: 'broccoli.build',
description: 'Broccoli.js - The asset pipeline for ambitious web applications',
url: 'https://broccoli.build',
menu,
},
});
let css = sassLint(appRoot + '/styles', {
disableTestGenerator: true,
});
css = compileSass([css, 'node_modules'], 'site.scss', 'assets/site.css', {
annotation: 'Sass files',
sourceMap: true,
sourceMapContents: true,
});
if (isProduction) {
css = new CleanCss(css);
}
const pub = funnel('src/public', {
annotation: 'Public assets',
});
let tree = merge([markdown, css, pub]);
if (isProduction) {
tree = assetRev(tree, {
extensions: ['js', 'css', 'png', 'jpg', 'gif', 'webmanifest', 'svg'],
});
} else {
tree = new LiveReload(tree, {
target: '\\.html$',
});
}
return tree;
};