forked from eduridden/moodle-theme_elegance
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Gruntfile.js
125 lines (112 loc) · 3.6 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
'use strict';
module.exports = function(grunt) {
// Import modules.
var path = require("path");
// PHP strings for exec task.
var moodleroot = path.dirname(path.dirname(__dirname));
var dirrootopt = grunt.option("dirroot") || process.env.MOODLE_DIR || "";
// Allow user to explicitly define Moodle root dir.
if ("" !== dirrootopt) {
moodleroot = path.resolve(dirrootopt);
}
var PWD = process.cwd();
var decachephp = "../../admin/cli/purge_caches.php";
grunt.initConfig({
exec: {
decache: {
cmd: 'php "' + decachephp + '"',
callback: function(error) {
// The exec process will output error messages.
// Just add one to confirm success.
if (!error) {
grunt.log.writeln("Moodle theme cache reset.");
}
}
},
postcss: {
command: 'npm run postcss'
}
},
watch: {
// Watch for any changes to less files and compile.
files: ["scss/**/*.scss"],
tasks: ["compile"],
options: {
spawn: false,
livereload: true
}
},
stylelint: {
scss: {
options: {
syntax: "scss"
},
src: ["scss/**/*.scss"]
},
css: {
src: ["*/**/*.css"],
options: {
configOverrides: {
rules: {
// These rules have to be disabled in .stylelintrc for scss compat.
"at-rule-no-unknown": true,
"no-browser-hacks": [true, {"severity": "warning"}]
}
}
}
}
},
jshint: {
options: {
jshintrc: true
},
files: ["**/amd/src/*.js"]
},
uglify: {
dynamic_mappings: {
files: grunt.file.expandMapping(
["**/src/*.js", "!**/node_modules/**"],
"",
{
cwd: PWD,
rename: function(destBase, destPath) {
destPath = destPath.replace("src", "build");
destPath = destPath.replace(".js", ".min.js");
destPath = path.resolve(PWD, destPath);
return destPath;
}
}
)
}
},
sass: {
options: {
style: 'expanded'
},
dist: {
files: {
'style/elegance.css': 'scss/gruntcompile.scss'
}
}
},
});
// Load contrib tasks.
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-exec");
// Load core tasks.
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-sass");
grunt.loadNpmTasks("grunt-stylelint");
// Register CSS taks.
grunt.registerTask("css", ["stylelint:scss", "stylelint:css"]);
// Register tasks.
grunt.registerTask("default", ["watch"]);
grunt.registerTask("decache", ["exec:decache"]);
grunt.registerTask("compile", [
"sass",
"exec:postcss",
"decache"
]);
grunt.registerTask("amd", ["jshint", "uglify"]);
};