-
Notifications
You must be signed in to change notification settings - Fork 0
/
gruntfile.js
104 lines (101 loc) · 3.08 KB
/
gruntfile.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
module.exports = function(grunt) {
// Configuration
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
dev: {
options: {
style: 'compressed',
lineNumbers: false,
// add to the list of paths to prepend to SASS @import functions
loadPath: [
'node_modules',
'src/sass'
]
},
files: [{
expand: true,
cwd: 'src/sass/',
src: ['main.scss'],
dest: 'dist/assets/css/',
ext: '.css'
}]
}
},
// ahoy! complicated stuff ahead!
// https://github.com/TypeStrong/tsify/issues/92
// convert TS to ES6 (tsify), then ES6 to ES5 with Babel (babelify)
// THEN bundle the JS modules together using Browserify
// we then minify the bundle separately with uglify and
// output to dist
browserify: {
options: {
plugin: [
['tsify', { target: 'es2016' }],
],
transform: ['babelify'],
extensions: ['.js', '.ts']
},
dev: {
options: {
browserifyOptions: {
debug: true
}
},
src: ['src/js/main.ts'],
dest: 'src/js/bundle.js'
}
},
uglify: {
dev: {
options: {
sourceMap: true
},
files: {
'dist/assets/js/main.min.js': ['src/js/bundle.js']
}
}
},
watch: {
configFiles: {
files: ['Gruntfile.js'],
options: {
reload: true // re-initialize grunt to apply changes
}
},
sass: {
files: [
'src/sass/**/*.scss',
'src/components/**/*.scss'
],
tasks: ['sass'],
options: {
spawn: true // forces watch to bail out completely on an error
}
},
ts: {
files: [
'src/js/**/*.ts'
],
tasks: ['browserify'],
options: {
spawn: true
}
},
js: {
files: [
'src/js/bundle.js'
],
tasks: ['uglify'],
options: {
spawn: true
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.registerTask('compile-js', ['browserify:dev', 'uglify:dev']);
};