-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
100 lines (94 loc) · 3.04 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
/**
* Gruntfile for compiling plugin .scss files AND .vue files.
*
* This file configures tasks to be run by Grunt
* http://gruntjs.com/ for the current theme.
*
* Requirements:
* nodejs, npm, grunt-cli.
*
* Installation:
* node and npm: instructions at http://nodejs.org/
* grunt-cli: `[sudo] npm install -g grunt-cli`
* node dependencies: run `npm install` in the root directory.
*
* Usage:
* Default behaviour is to watch all .less files and compile
* into compressed CSS when a change is detected to any and then
* clear the theme's caches. Invoke either `grunt` or `grunt watch`
* in the theme's root directory.
*
* To separately compile only moodle or editor .less files
* run `grunt less:moodle` or `grunt less:editor` respectively.
*
* To only clear the theme caches invoke `grunt exec:decache` in
* the theme's root directory.
*
* @author Joby Harding / David Scotson / Stuart Lamour / Guy Thomas (vue files and es5 transpilation)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
const sass = require('node-sass');
module.exports = function(grunt) {
// We need to include the core Moodle grunt file too, so that we can run the tasks that are defined there.
require("grunt-load-gruntfile")(grunt);
grunt.loadGruntfile("../../../Gruntfile.js");
grunt.mergeConfig = grunt.config.merge;
grunt.mergeConfig({
sass: {
compile: {
options: {
compress: false,
implementation: sass,
sourceMap: true
},
files: {
"styles.css": "scss/styles.scss",
}
}
},
sasslint: {
src: "styles.css",
target: "scss/styles.scss"
},
autoprefixer: {
options: {
browsers: [
'Android 2.3',
'Android >= 4',
'Chrome >= 20',
'Firefox >= 24', // Firefox 24 is the latest ESR.
'Explorer >= 9',
'iOS >= 6',
'Opera >= 12.1',
'Safari >= 6'
]
},
core: {
options: {
map: false
},
src: ['styles.css'],
},
},
watch: {
// Watch for any changes to sass files and compile.
sass: {
files: ["scss/*.scss"],
tasks: ["compile"],
options: {
spawn: false
}
}
}
});
// Load contrib tasks.
grunt.loadNpmTasks("grunt-autoprefixer");
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-sass-lint');
grunt.loadNpmTasks("grunt-sass");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-exec");
// Register tasks.
grunt.registerTask("default", ["watch"]);
grunt.registerTask("compile", ["sass:compile", "autoprefixer"]);
};