-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntfile.js
More file actions
executable file
·123 lines (119 loc) · 3.19 KB
/
Gruntfile.js
File metadata and controls
executable file
·123 lines (119 loc) · 3.19 KB
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
const sass = require("sass");
const autoprefixer = require("autoprefixer");
const postcssPxtorem = require("postcss-pxtorem");
const webpackConfig = require('./webpack.config.js');
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
webpack: {
myConfig: webpackConfig,
},
babel: {
options: {
sourceMap: false,
},
dist: {
files: [
{
expand: true,
cwd: 'js/dist/',
src: ['*.js', '!dxpr-theme-header.js',
'!dxpr-theme-multilevel-mobile-nav.js',
'!dxpr-theme-settings-admin.js',
'!dxpr-theme-settings-sidebar.js',
],
dest: 'js/minified/',
ext: '.min.js',
},
],
},
},
terser: {
options: {
ecma: 2022,
},
main: {
files: [
{
expand: true,
cwd: 'js/minified/',
src: ['*.min.js', '!dxpr-theme-header.bundle.min.js',
'!dxpr-theme-multilevel-mobile-nav.bundle.min.js',
'!dxpr-theme-settings-admin.bundle.min.js',
'!dxpr-theme-settings-sidebar.bundle.min.js'],
dest: 'js/minified/',
ext: '.min.js',
},
],
},
},
sass: {
options: {
implementation: sass,
sourceMap: false,
outputStyle: "compressed",
},
dist: {
files: [
{
expand: true,
cwd: "scss/",
src: "**/*.scss",
dest: "css/",
ext: ".css",
extDot: "last",
},
],
},
},
postcss: {
options: {
processors: [
autoprefixer(),
postcssPxtorem({
rootValue: 16,
unitPrecision: 5,
propList: ["*"],
selectorBlackList: [],
replace: true,
mediaQuery: true,
minPixelValue: 0,
}),
],
},
dist: {
src: "css/**/*.css",
},
},
watch: {
css: {
files: ["scss/**/*.scss"],
tasks: ["sass", "postcss"],
},
js: {
files: ["js/dist/**/*.js", "!js/minified/**/*.js"],
tasks: ["webpack", "babel", "terser"],
},
schema: {
files: ["features/**/*-theme-settings.inc"],
tasks: ["generate-schema"],
},
},
});
grunt.loadNpmTasks("grunt-webpack");
grunt.loadNpmTasks("grunt-babel");
grunt.loadNpmTasks("grunt-terser");
grunt.loadNpmTasks("grunt-sass");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("@lodder/grunt-postcss");
grunt.registerTask("generate-schema", "Generate settings-schema.json from PHP inc files", function () {
const done = this.async();
const { execFile } = require("child_process");
execFile("node", ["scripts/generate-settings-schema.js"], { cwd: __dirname }, (err, stdout, stderr) => {
if (stdout) grunt.log.write(stdout);
if (stderr) grunt.log.error(stderr);
done(!err);
});
});
grunt.registerTask("default", ["watch"]);
};