-
Notifications
You must be signed in to change notification settings - Fork 8
/
Gruntfile.js
136 lines (130 loc) · 4 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/* eslint no-undef: "error" */
/* eslint camelcase: 2 */
/* eslint-env node */
"use strict";
/**
* Gruntfile for the plugin.
*
* This file configures tasks to be run by Grunt
* https://gruntjs.com/ for the current theme.
*
*
* Requirements:
* -------------
* nodejs, npm, grunt-cli.
*
* Installation:
* -------------
* node and npm: instructions at https://nodejs.org/
*
* run for each task (and grunt-cli): `[sudo] npm install -g grunt-cli --save-dev`
* run for each task to install locally:: `[sudo] npm install grunt-cli --save-dev`
*
* node dependencies: run `npm install` in the root directory.
*
*
* Usage:
* ------
* Call tasks from the plugin root directory. Default behaviour
* (calling only `grunt`) is to run the watch task detailed below.
*
*
* Porcelain tasks:
* ----------------
* The nice user interface intended for everyday use. Provide a
* high level of automation and convenience for specific use-cases.
*
* grunt css Create CSS from the SCSS.
*
*
* Based on https://github.com/willianmano/moodle-theme_moove/ Gruntfile.js - thank you!
* Based on https://gitlab.com/jezhops/moodle-theme_adaptable/ Gruntfile.js - thank you!
*
* @package block_advnotifications
* @author Based on code originally written by:
* Willian Mano - {@link https://conecti.me} & G J Barnard - {@link https://moodle.org/user/profile.php?id=442195}
* @copyright 2020 LearningWorks <selma@learningworks.ac.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
module.exports = function(grunt) {
let decachephp = "../../admin/cli/purge_caches.php";
const sass = require('node-sass');
grunt.initConfig({
watch: {
options: {
nospawn: true,
livereload: true
},
css: {
files: ["scss/**/*.scss"],
tasks: ["css", "decache"]
},
js: {
files: ["amd/src/*.js"],
tasks: ["uglify", "decache"]
}
},
sass: {
dist: {
files: {
"styles.css": "scss/styles.scss"
}
},
options: {
includePaths: ["scss"],
implementation: sass,
indentWidth: 4,
outputStyle: "expanded"
}
},
stylelint: {
scss: {
options: {syntax: "scss"},
src: ["scss/**/*.scss"]
},
css: {
src: ["styles.css"],
options: {
configOverrides: {
rules: {
"at-rule-no-unknown": true,
}
}
}
}
},
uglify: {
dist: {
files: {
'amd/build/custom.min.js': 'amd/src/custom.js',
'amd/build/notif.min.js': 'amd/src/notif.js',
}
}
},
exec: {
decache: {
cmd: "php " + decachephp,
callback: function(error) {
if (!error) {
grunt.log.writeln("Moodle caches purged.");
} else {
grunt.log.writeln("Some error occurred:");
grunt.log.writeln(error);
}
}
}
}
});
// Load tasks.
grunt.loadNpmTasks("grunt-exec");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks("grunt-stylelint");
grunt.loadNpmTasks('grunt-contrib-uglify');
// Register tasks.
grunt.registerTask("default", ["watch"]);
grunt.registerTask("css", ["stylelint:scss", "sass", "stylelint:css"]);
grunt.registerTask("stylecheck", ["stylelint:scss", "stylelint:css"]);
grunt.registerTask("js", ["uglify"]);
grunt.registerTask("decache", ["exec:decache"]);
};