-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGruntfile.js
116 lines (109 loc) · 3.75 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
105
106
107
108
109
110
111
112
113
114
115
116
//var packageJson = require("./package.json");
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
browserify: {
dist: {
options: {
browserifyOptions: {
// Enable inline sourcemap generation so that
// stack traces reference the original files' lines
debug: true
},
transform: [
]
},
files: {
// if the source file has an extension of es6 then
// we change the name of the source file accordingly.
// The result file's extension is always .js
"./dist/annotator-frontend.js": ["./modules/main.js"]
}
}
},
sass: {
dist: {
files: {
'./dist/annotator-frontend.css': './sass/main.scss'
}
}
},
watch: {
scripts: {
//Build packed file when any source files change
files: ["./modules/**/*.js"],
tasks: ["browserify", "extract_sourcemap"]
},
styles: {
//Build packed file when any style files change
files: ["./sass/**/*.scss"],
tasks: ["sass"]
},
system: {
files: ["./Gruntfile.js", "./package.json"],
tasks: ["build"]
}
// ,postbuild: {
// files: ["./dist/*.js"],
// tasks: ["extract_sourcemap"]
// }
},
browserSync: {
default_options: {
bsFiles: {
// BrowserSync will reload if any of the following files are changed.
src: [
"./testpage/**/*.js",
"./testpage/**/*.html",
"./testpage/**/*.css",
"./dist/**/*.css",
"./dist/**/*.js"
]
},
options: {
watchTask: true,
server: {
baseDir: "./",
index: "./testpage/index.html"
}
}
}
},
extract_sourcemap: {
// Task to extract the inline sourcemap from the built file
// so that Chrome can use it for debug purposes (stack traces
// will point to original source files)
files: {
'./dist': ['./dist/annotator-frontend.js'],
},
},
compress: {
main: {
options: {
archive: function () {
// Build zip file string here
return "waldorf.zip";
}
},
files: [{
expand: true,
cwd: "./",
src: ["dist/*"],
dest: "./"
}]
}
},
test: {
}
});
grunt.loadNpmTasks("grunt-browserify");
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks('grunt-browser-sync');
grunt.loadNpmTasks('grunt-extract-sourcemap');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.registerTask("build", ["sass", "browserify"]);
grunt.registerTask("preview", ["build", "browserSync", "watch"]);
grunt.registerTask("make_release", ["build", "compress"]);
grunt.registerTask("test", ["test"]);
};