-
Notifications
You must be signed in to change notification settings - Fork 3
/
Gruntfile.js
129 lines (113 loc) · 3.94 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
/*!
* Bootstrap's Gruntfile
* https://getbootstrap.com
* Copyright 2013-2017 The Bootstrap Authors
* CopyrLicensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
var APNSCP_PATH = process.env['APNSCP_PATH'] || "/usr/local/apnscp",
THEME_PATH = process.env['APNSCP_THEME_PATH'] || (APNSCP_PATH + "/public/css/themes"),
THEME = process.env['THEME'] || "apnscp";
module.exports = function (grunt) {
'use strict'
// Force use of Unix newlines
grunt.util.linefeed = '\n'
RegExp.quote = function (string) {
return string.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&')
}
const path = require('path')
const inliner = require('sass-inline-svg');
const sass = require('node-sass');
const Fiber = require('fibers');
// Project configuration.
var config = {
// Metadata.
pkg: grunt.file.readJSON('package.json'),
banner: '/*!\n' +
' * Bootstrap v<%= pkg.version %> (<%= pkg.homepage %>)\n' +
' * Copyright 2011-<%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
' * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n' +
' */\n',
// Task configuration.
clean: {
dist: 'dist',
},
// CSS build configuration
copy: {
css: {
expand: true,
cwd: 'dist/css/',
src: [
'*'
],
dest: APNSCP_PATH + '/public/css/themes'
}
},
watch: {
sass: {
files: ['scss/**/*.scss', 'scss/**/*.svg'],
tasks: ['sass-compile', 'copy:css']
},
},
exec: {
'clean-css': {
command: 'cleancss --skip-advanced --source-map --output dist/css/' + THEME + '.min.css dist/css/' + THEME + '.css'
},
postcss: {
command: 'npm run postcss'
},
'scss-clean': {
command: "cleancss --skip-advanced --source-map --output dist/css/" + THEME + ".min.css dist/css/" + THEME + ".css"
},
'scss-lint': {
command: 'npm run scss-lint'
},
uglify: {
command: 'npm run uglify'
},
},
compress: {
main: {
options: {
archive: 'apnscp-' + THEME + '-<%= pkg.version %>-dist.zip',
mode: 'zip',
level: 9,
pretty: true
},
files: [
{
expand: true,
cwd: 'dist/',
src: ['**'],
dest: 'apnscp-' + THEME + '-<%= pkg.version %>-dist'
}
]
}
},
sass: {
dist: {
options: {
functions: {
"svg": inliner('scss/apnscp/media', {optimize: true, encodingFormat: "uri"})
},
implementation: sass,
sourceMap: true,
fiber: Fiber,
precision: 6,
outputStyle: "expanded"
},
files: {}
},
}
};
config.sass.dist.files["dist/css/" + THEME + ".css"] = "scss/themes/" + THEME + ".scss";
grunt.initConfig(config)
require('jit-grunt')(grunt)
require('time-grunt')(grunt)
grunt.registerTask('test-scss', ['exec:scss-lint'])
grunt.registerTask('sass-compile', ['sass', 'copy:css'])
grunt.registerTask('dist-css', ['sass-compile', 'exec:postcss', 'exec:clean-css', 'copy:css'])
// Full distribution task.
grunt.registerTask('dist', ['clean:dist', 'dist-css'])
grunt.registerTask('default', ['dist']);
grunt.registerTask('prep-release', ['dist', 'compress'])
}