forked from kbase/narrative
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
65 lines (60 loc) · 2.16 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
const crypto = require('crypto');
module.exports = function (grunt) {
'use strict';
require('load-grunt-tasks')(grunt);
grunt.initConfig({
// This inserts the reference to the compiled, minified JS file into page.html at
// the right spot (in place of `narrativeMain`, which is used locally)
'regex-replace': {
dist: {
src: ['kbase-extension/kbase_templates/notebook.html'],
actions: [
{
name: 'requirejs-onefile',
search: 'narrativeMain.js',
replace: function () {
const cbString = crypto.randomBytes(4).toString('hex');
return `kbase-narrative-min.js?cb=${cbString}`;
},
flags: '',
},
],
},
},
// Run CSS / SCSS-related tasks
// these files are modified in place
postcss: {
// autoprefix and minify the concatenated css files
concat: {
options: {
processors: [
// add vendor prefixes
require('autoprefixer')(),
// minify
require('cssnano')([
'default',
{
normalizeWhitespace: {
exclude: true,
},
},
]),
],
},
src: ['kbase-extension/static/kbase/css/all_concat.css'],
},
},
// runs the npm command to compile scss -> css and run autoprefixer on it
shell: {
compile_css: {
command: 'npm run compile_css',
},
},
// watch scss files for any changes
// when they change, regenerate the compiled css files
watch: {
files: 'kbase-extension/scss/**/*.scss',
tasks: ['shell:compile_css'],
},
});
};