-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGruntfile.js
116 lines (109 loc) · 3.2 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
/* eslint no-undef: "error" */
/* eslint camelcase: 2 */
/* eslint-env node */
"use strict";
/**
* Gruntfile for the SELMA enrol 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: `[sudo] npm install -g 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 enrol_selma
* @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";
grunt.initConfig({
watch: {
options: {
nospawn: true,
livereload: true
},
css: {
files: ["scss/**/*.scss"],
tasks: ["css", "decache"]
}
},
sass: {
dist: {
files: {
"styles.css": "scss/main.scss"
}
},
options: {
includePaths: ["scss/"]
}
},
stylelint: {
scss: {
options: {syntax: "scss"},
src: ["scss/**/*.scss"]
},
css: {
src: ["styles.css"],
options: {
configOverrides: {
rules: {
"at-rule-no-unknown": true,
}
}
}
}
},
exec: {
decache: {
cmd: "php " + decachephp,
callback: function(error) {
if (!error) {
grunt.log.writeln("Moodle caches purged.");
} else {
grunt.log.writeln("Some error occured:");
grunt.log.writeln(error);
}
}
}
}
});
// Load tasks.
grunt.loadNpmTasks("grunt-exec");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks("grunt-stylelint");
// Register tasks.
grunt.registerTask("default", ["watch"]);
grunt.registerTask("css", ["stylelint:scss", "sass"]);
grunt.registerTask("decache", ["exec:decache"]);
};