forked from substance/texture
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake.js
97 lines (82 loc) · 2.7 KB
/
make.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
var b = require('substance-bundler');
b.task('clean', function() {
b.rm('./dist')
})
// copy assets
b.task('assets', function() {
b.copy('examples/index.html', './dist/')
b.copy('texture.css', './dist/')
b.copy('packages/**/*.css', './dist/')
b.copy('examples/data', './dist/data')
b.copy('node_modules/font-awesome', './dist/font-awesome')
})
// this optional task makes it easier to work on Substance core
b.task('substance', function() {
b.make('substance', 'clean', 'css', 'browser')
b.copy('node_modules/substance/dist', './dist/substance')
})
b.task('substance:all', function() {
b.make('substance')
})
function buildExample(example) {
return function() {
b.copy('examples/'+example+'/index.html', './dist/'+example+'/')
b.copy('examples/'+example+'/*.css', './dist/'+example+'/', { root: 'examples/'+example })
b.js('examples/'+example+'/app.js', {
// need buble if we want to minify later
// buble: true,
external: ['substance'],
commonjs: { include: ['node_modules/lodash/**'] },
dest: './dist/'+example+'/app.js',
format: 'umd',
moduleName: example
})
}
}
b.task('author', ['clean', 'substance', 'assets'], buildExample('author'))
b.task('authorEmpty', ['clean', 'substance', 'assets'], buildExample('authorEmpty'))
b.task('publisher', ['clean', 'substance', 'assets'], buildExample('publisher'))
b.task('tagging', ['author'], buildExample('tagging'))
b.task('examples', ['author', 'publisher', 'tagging', 'authorEmpty'])
// build all
b.task('default', ['examples'])
b.task('test:clean', function() {
b.rm('dist/test')
})
b.task('test:assets', function() {
b.copy('./node_modules/substance-test/dist/*', './dist/test', { root: './node_modules/substance-test/dist' })
})
b.task('test:browser', function() {
b.js('./test/index.js', {
// buble necessary here, as travis has old browser versions
buble: true,
ignore: ['substance-cheerio'],
external: ['substance-test', 'substance'],
commonjs: { include: ['node_modules/lodash/**'] },
targets: [
{ dest: './dist/test/tests.js', format: 'umd', moduleName: 'tests' }
]
});
})
b.task('test:server', function() {
b.js('./test/index.js', {
// buble necessary here, for nodejs
buble: true,
external: ['substance-test', 'substance'],
commonjs: {
include: [
'node_modules/lodash/**',
'node_modules/substance-cheerio/**'
]
},
targets: [
{ dest: './dist/test/run-tests.js', format: 'cjs' },
]
});
})
b.task('test', ['substance:all', 'test:clean', 'test:assets', 'test:browser', 'test:server'])
// starts a server when CLI argument '-s' is set
b.setServerPort(5555)
b.serve({
static: true, route: '/', folder: 'dist'
})