This repository has been archived by the owner on Aug 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Gruntfile.js
136 lines (121 loc) · 5.47 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
/*global module:false*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
// Load in the package information.
pkg: grunt.file.readJSON("package.json"),
// Load in your sorry credentials.
// NOTE: NEVER CHECK YOUR CREDENTIALS INTO YOUR REPOSITORY.
sorry: grunt.file.readJSON('sorry.json'),
// Sorry theme deployment.
sorry_theme_deploy: {
options: {
accessToken: '<%= sorry.accessToken %>'
},
theme: {
expand: true,
cwd: 'build/',
src: ['**/*']
}
},
// Clean the build directory before we do anything.
clean: ["build/"],
// Javascript validation.
jshint: {
// Validate the gruntfile and theme src.
all: ["Gruntfile.js", "src/assets/*.js"]
},
// JS Minification + Concatination.
uglify: {
my_target: {
files: {
'build/assets/status-page.min.js': [
'src/javascripts/vendor/jquery-3.6.1.js',
//'src/javascripts/vendor/bootstrap/transition.js',
//'src/javascripts/vendor/bootstrap/alert.js',
//'src/javascripts/vendor/bootstrap/button.js',
//'src/javascripts/vendor/bootstrap/carousel.js',
'src/javascripts/vendor/bootstrap/collapse.js',
'src/javascripts/vendor/bootstrap/dropdown.js',
//'src/javascripts/vendor/bootstrap/modal.js',
//'src/javascripts/vendor/bootstrap/tooltip.js',
//'src/javascripts/vendor/bootstrap/popover.js',
//'src/javascripts/vendor/bootstrap/scrollspy.js',
//'src/javascripts/vendor/bootstrap/tab.js',
//'src/javascripts/vendor/bootstrap/affix.js',
'src/javascripts/vendor/moment-with-locales.js',
'src/javascripts/vendor/moment-timezone.js',
'src/javascripts/vendor/is-element-in-viewport.js',
'src/javascripts/smart-anchor.js',
'src/javascripts/status-page.js',
'src/javascripts/truncate.js'
]
}
}
},
// LESS CSS Compilation.
// Compile the LESS source into the build directory.
less: {
production: {
options: {
cleancss: true,
},
files: {
"build/assets/status-page.css": "src/stylesheets/main.less",
}
}
},
// Source files into the build directory.
copy: {
main: {
files: [
// Copy the liquid template from src to the build folder for push.
{ expand: true, flatten: true, src: "src/status-page.liquid", dest: "build/"},
// Copy the error page template into the build folder.
{ expand: true, flatten: true, src: "src/error-page.liquid", dest: "build/"},
// Copy the maintenance page template into the build folder.
{ expand: true, flatten: true, src: "src/maintenance-page.liquid", dest: "build/"},
// Copy the various layout files to the dist folder.
{ expand: true, flatten: true, cwd: "src/layouts/", src: "**", dest: "build/layouts"},
// Copy javascript assets.
{ expand: true, flatten: true, cwd: "src/javascripts/", src: "**/*.min.js", dest: "build/assets/"},
// Copy webfont assets.
{ expand: true, flatten: true, cwd: "src/fonts/", src: "**", dest: "build/assets/"},
// Copy image assets.
{ expand: true, flatten: true, cwd: "src/images/", src: "**", dest: "build/assets/"},
// Copy Locale files.
{ expand: true, flatten: true, cwd: "src/locales/", src: "**", dest: "build/locales"},
// Copy include files, mainteain nested directory.
{ expand: true, flatten: false, cwd: "src/includes/", src: "**", dest: "build/includes"}
]
},
},
// Auto-deploy on file changes to theme src.
watch: {
theme: {
files: 'src/**/*',
tasks: ['deploy'],
options: {
interrupt: true,
}
}
},
// Release / Version of the theme as Github tags.
release: {
options: {
npm: false // Don't publish the theme to NPM as not a node package.
}
},
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks("grunt-contrib-less");
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-sorry-theme-deploy');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-release');
grunt.loadNpmTasks('grunt-contrib-uglify');
// Default task(s).
grunt.registerTask("deploy", ["jshint", "clean", "uglify", "less", "copy", "sorry_theme_deploy"]);
};