-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathgobblefile.js
89 lines (76 loc) · 2.33 KB
/
gobblefile.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
var gobble = require( 'gobble' );
var sander = require( 'sander' );
var compileTutorials = require( './gobble/compile-tutorials' );
var prod = gobble.env() === 'production';
var common = gobble( 'node_modules/ractive-www' );
var components = gobble([ common.grab( 'components' ), 'src/app/components' ]).moveTo( 'components' );
var babelWhitelist = [
'es6.arrowFunctions',
'es6.blockScoping',
'es6.classes',
'es6.constants',
'es6.destructuring',
'es6.parameters.default',
'es6.parameters.rest',
'es6.properties.shorthand',
'es6.spread',
'es6.templateLiterals'
];
var assets = gobble([ common.grab( 'assets' ).moveTo( 'assets' ), 'src/assets' ]);
var app = (function () {
var app = gobble([ 'src/app', components ])
.transform( 'ractive', { type: 'es6' })
.transform( 'babel', { whitelist: babelWhitelist })
.transform( 'esperanto-bundle', {
entry: 'app',
type: 'cjs'
})
.transform( 'derequire' )
.transform( 'browserify', {
entries: [ './app' ],
dest: 'app.js',
debug: true,
standalone: 'app'
});
return prod ? app.transform( 'uglifyjs' ) : app;
}());
var bundle = gobble([
gobble( 'vendor', { static: true }),
gobble( 'node_modules', { static: true })
])
.transform( 'concat', {
files: [
// from node_modules
'codemirror/lib/codemirror.js',
'codemirror/mode/javascript/javascript.js',
'codemirror/mode/xml/xml.js',
'codemirror/mode/htmlmixed/htmlmixed.js',
'codemirror/keymap/sublime.js',
'codemirror/addon/search/search.js',
'codemirror/addon/search/searchcursor.js',
// from vendor. TODO replace with hljs?
'google-code-prettify/src/prettify.js'
],
dest: 'bundle.js'
});
if ( prod ) {
bundle = bundle.map( 'uglifyjs' );
}
var css = gobble([ 'src/styles', common.grab( 'scss' ).moveTo( 'common' ) ])
.transform( 'sass', {
src: 'main.scss',
dest: 'main.css',
outputStyle: 'compressed'
});
var tutorials = gobble([
components.transform( 'ractive', { type: 'cjs' }),
gobble( 'src/tutorials' ).moveTo( 'tutorials' )
])
.transform( copy )
.transform( compileTutorials );
function copy ( inputdir, outputdir, options ) {
// this is super hacky, but we need physical copies of the files
// on disk, not symlinks, because of how node's module resolver works
return sander.copydir( inputdir ).to( outputdir );
}
module.exports = gobble([ assets, app, bundle, css, tutorials ]);