2014-08-01 12:53:31 +00:00
|
|
|
module.exports = function( grunt ) {
|
2014-02-02 19:20:52 +00:00
|
|
|
'use strict';
|
2019-02-12 23:23:19 +00:00
|
|
|
var sass = require( 'node-sass' );
|
2014-01-30 16:11:02 +00:00
|
|
|
|
2014-02-02 19:22:05 +00:00
|
|
|
grunt.initConfig({
|
2014-08-29 21:04:13 +00:00
|
|
|
|
2014-10-23 21:42:07 +00:00
|
|
|
// Setting folder templates.
|
2014-02-02 19:24:02 +00:00
|
|
|
dirs: {
|
|
|
|
css: 'assets/css',
|
|
|
|
fonts: 'assets/fonts',
|
|
|
|
images: 'assets/images',
|
2019-02-23 01:00:47 +00:00
|
|
|
js: 'assets/js',
|
|
|
|
php: 'includes'
|
2014-02-02 19:24:02 +00:00
|
|
|
},
|
|
|
|
|
2020-05-04 19:27:15 +00:00
|
|
|
// JavaScript linting with ESLint.
|
|
|
|
eslint: {
|
|
|
|
src: [
|
2014-08-04 14:12:50 +00:00
|
|
|
'<%= dirs.js %>/admin/*.js',
|
|
|
|
'!<%= dirs.js %>/admin/*.min.js',
|
|
|
|
'<%= dirs.js %>/frontend/*.js',
|
2019-02-04 11:24:26 +00:00
|
|
|
'!<%= dirs.js %>/frontend/*.min.js'
|
2014-08-04 14:12:50 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
|
2016-08-08 19:32:39 +00:00
|
|
|
// Sass linting with Stylelint.
|
|
|
|
stylelint: {
|
|
|
|
options: {
|
2016-11-07 17:47:05 +00:00
|
|
|
configFile: '.stylelintrc'
|
2016-08-08 19:32:39 +00:00
|
|
|
},
|
|
|
|
all: [
|
2016-08-10 13:15:58 +00:00
|
|
|
'<%= dirs.css %>/*.scss',
|
|
|
|
'!<%= dirs.css %>/select2.scss'
|
2016-08-08 19:32:39 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
|
2014-02-02 20:47:06 +00:00
|
|
|
// Minify .js files.
|
|
|
|
uglify: {
|
|
|
|
options: {
|
2017-06-19 11:49:27 +00:00
|
|
|
ie8: true,
|
|
|
|
parse: {
|
|
|
|
strict: false
|
|
|
|
},
|
|
|
|
output: {
|
|
|
|
comments : /@license|@preserve|^!/
|
|
|
|
}
|
2014-02-02 20:47:06 +00:00
|
|
|
},
|
|
|
|
admin: {
|
|
|
|
files: [{
|
|
|
|
expand: true,
|
|
|
|
cwd: '<%= dirs.js %>/admin/',
|
|
|
|
src: [
|
|
|
|
'*.js',
|
2015-10-01 13:46:08 +00:00
|
|
|
'!*.min.js'
|
2014-02-02 20:47:06 +00:00
|
|
|
],
|
|
|
|
dest: '<%= dirs.js %>/admin/',
|
|
|
|
ext: '.min.js'
|
|
|
|
}]
|
|
|
|
},
|
2015-10-01 13:46:08 +00:00
|
|
|
vendor: {
|
2015-05-25 14:27:28 +00:00
|
|
|
files: {
|
2015-10-01 13:46:08 +00:00
|
|
|
'<%= dirs.js %>/accounting/accounting.min.js': ['<%= dirs.js %>/accounting/accounting.js'],
|
2015-02-02 16:11:05 +00:00
|
|
|
'<%= dirs.js %>/jquery-blockui/jquery.blockUI.min.js': ['<%= dirs.js %>/jquery-blockui/jquery.blockUI.js'],
|
|
|
|
'<%= dirs.js %>/jquery-cookie/jquery.cookie.min.js': ['<%= dirs.js %>/jquery-cookie/jquery.cookie.js'],
|
2016-11-22 15:09:37 +00:00
|
|
|
'<%= dirs.js %>/js-cookie/js.cookie.min.js': ['<%= dirs.js %>/js-cookie/js.cookie.js'],
|
2015-10-01 13:46:08 +00:00
|
|
|
'<%= dirs.js %>/jquery-flot/jquery.flot.min.js': ['<%= dirs.js %>/jquery-flot/jquery.flot.js'],
|
|
|
|
'<%= dirs.js %>/jquery-flot/jquery.flot.pie.min.js': ['<%= dirs.js %>/jquery-flot/jquery.flot.pie.js'],
|
|
|
|
'<%= dirs.js %>/jquery-flot/jquery.flot.resize.min.js': ['<%= dirs.js %>/jquery-flot/jquery.flot.resize.js'],
|
|
|
|
'<%= dirs.js %>/jquery-flot/jquery.flot.stack.min.js': ['<%= dirs.js %>/jquery-flot/jquery.flot.stack.js'],
|
|
|
|
'<%= dirs.js %>/jquery-flot/jquery.flot.time.min.js': ['<%= dirs.js %>/jquery-flot/jquery.flot.time.js'],
|
2015-05-25 14:42:42 +00:00
|
|
|
'<%= dirs.js %>/jquery-payment/jquery.payment.min.js': ['<%= dirs.js %>/jquery-payment/jquery.payment.js'],
|
2015-06-08 21:31:19 +00:00
|
|
|
'<%= dirs.js %>/jquery-qrcode/jquery.qrcode.min.js': ['<%= dirs.js %>/jquery-qrcode/jquery.qrcode.js'],
|
2019-01-30 08:12:08 +00:00
|
|
|
'<%= dirs.js %>/jquery-serializejson/jquery.serializejson.min.js': [
|
|
|
|
'<%= dirs.js %>/jquery-serializejson/jquery.serializejson.js'
|
|
|
|
],
|
2015-05-25 14:42:42 +00:00
|
|
|
'<%= dirs.js %>/jquery-tiptip/jquery.tipTip.min.js': ['<%= dirs.js %>/jquery-tiptip/jquery.tipTip.js'],
|
2019-01-30 08:12:08 +00:00
|
|
|
'<%= dirs.js %>/jquery-ui-touch-punch/jquery-ui-touch-punch.min.js': [
|
|
|
|
'<%= dirs.js %>/jquery-ui-touch-punch/jquery-ui-touch-punch.js'
|
|
|
|
],
|
2015-05-25 14:42:42 +00:00
|
|
|
'<%= dirs.js %>/prettyPhoto/jquery.prettyPhoto.init.min.js': ['<%= dirs.js %>/prettyPhoto/jquery.prettyPhoto.init.js'],
|
|
|
|
'<%= dirs.js %>/prettyPhoto/jquery.prettyPhoto.min.js': ['<%= dirs.js %>/prettyPhoto/jquery.prettyPhoto.js'],
|
2016-10-13 14:25:42 +00:00
|
|
|
'<%= dirs.js %>/flexslider/jquery.flexslider.min.js': ['<%= dirs.js %>/flexslider/jquery.flexslider.js'],
|
|
|
|
'<%= dirs.js %>/zoom/jquery.zoom.min.js': ['<%= dirs.js %>/zoom/jquery.zoom.js'],
|
|
|
|
'<%= dirs.js %>/photoswipe/photoswipe.min.js': ['<%= dirs.js %>/photoswipe/photoswipe.js'],
|
|
|
|
'<%= dirs.js %>/photoswipe/photoswipe-ui-default.min.js': ['<%= dirs.js %>/photoswipe/photoswipe-ui-default.js'],
|
2015-10-01 13:46:08 +00:00
|
|
|
'<%= dirs.js %>/round/round.min.js': ['<%= dirs.js %>/round/round.js'],
|
2019-04-23 19:39:50 +00:00
|
|
|
'<%= dirs.js %>/selectWoo/selectWoo.full.min.js': ['<%= dirs.js %>/selectWoo/selectWoo.full.js'],
|
|
|
|
'<%= dirs.js %>/selectWoo/selectWoo.min.js': ['<%= dirs.js %>/selectWoo/selectWoo.js'],
|
2015-05-25 14:42:42 +00:00
|
|
|
'<%= dirs.js %>/stupidtable/stupidtable.min.js': ['<%= dirs.js %>/stupidtable/stupidtable.js'],
|
|
|
|
'<%= dirs.js %>/zeroclipboard/jquery.zeroclipboard.min.js': ['<%= dirs.js %>/zeroclipboard/jquery.zeroclipboard.js']
|
2014-02-02 20:47:06 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
frontend: {
|
|
|
|
files: [{
|
|
|
|
expand: true,
|
|
|
|
cwd: '<%= dirs.js %>/frontend/',
|
|
|
|
src: [
|
|
|
|
'*.js',
|
|
|
|
'!*.min.js'
|
|
|
|
],
|
|
|
|
dest: '<%= dirs.js %>/frontend/',
|
|
|
|
ext: '.min.js'
|
|
|
|
}]
|
2014-11-14 11:58:21 +00:00
|
|
|
},
|
2018-05-31 09:44:52 +00:00
|
|
|
flexslider: {
|
2014-11-14 11:58:21 +00:00
|
|
|
files: [{
|
2018-05-31 09:44:52 +00:00
|
|
|
'<%= dirs.js %>/flexslider/jquery.flexslider.min.js': ['<%= dirs.js %>/flexslider/jquery.flexslider.js']
|
2014-11-14 11:58:21 +00:00
|
|
|
}]
|
2014-09-22 16:55:53 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// Compile all .scss files.
|
|
|
|
sass: {
|
|
|
|
compile: {
|
2014-09-26 13:00:36 +00:00
|
|
|
options: {
|
2019-01-30 08:12:08 +00:00
|
|
|
implementation: sass,
|
2017-06-26 17:16:46 +00:00
|
|
|
sourceMap: 'none'
|
2014-09-26 13:00:36 +00:00
|
|
|
},
|
2014-09-22 16:55:53 +00:00
|
|
|
files: [{
|
|
|
|
expand: true,
|
|
|
|
cwd: '<%= dirs.css %>/',
|
|
|
|
src: ['*.scss'],
|
|
|
|
dest: '<%= dirs.css %>/',
|
|
|
|
ext: '.css'
|
|
|
|
}]
|
|
|
|
}
|
2014-02-02 20:47:06 +00:00
|
|
|
},
|
|
|
|
|
2018-05-22 12:40:30 +00:00
|
|
|
// Generate RTL .css files.
|
2017-01-20 18:29:48 +00:00
|
|
|
rtlcss: {
|
|
|
|
woocommerce: {
|
|
|
|
expand: true,
|
|
|
|
cwd: '<%= dirs.css %>',
|
|
|
|
src: [
|
|
|
|
'*.css',
|
2017-02-10 19:39:28 +00:00
|
|
|
'!select2.css',
|
2017-01-20 18:29:48 +00:00
|
|
|
'!*-rtl.css'
|
|
|
|
],
|
|
|
|
dest: '<%= dirs.css %>/',
|
|
|
|
ext: '-rtl.css'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-08-04 14:12:50 +00:00
|
|
|
// Minify all .css files.
|
|
|
|
cssmin: {
|
|
|
|
minify: {
|
2019-11-19 18:40:28 +00:00
|
|
|
files: [
|
|
|
|
{
|
|
|
|
expand: true,
|
|
|
|
cwd: '<%= dirs.css %>/',
|
|
|
|
src: ['*.css'],
|
|
|
|
dest: '<%= dirs.css %>/',
|
|
|
|
ext: '.css'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
expand: true,
|
|
|
|
cwd: '<%= dirs.css %>/photoswipe/',
|
|
|
|
src: ['*.css', '!*.min.css'],
|
|
|
|
dest: '<%= dirs.css %>/photoswipe/',
|
|
|
|
ext: '.min.css'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
expand: true,
|
|
|
|
cwd: '<%= dirs.css %>/photoswipe/default-skin/',
|
|
|
|
src: ['*.css', '!*.min.css'],
|
|
|
|
dest: '<%= dirs.css %>/photoswipe/default-skin/',
|
|
|
|
ext: '.min.css'
|
|
|
|
}
|
|
|
|
]
|
2014-08-04 14:12:50 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-02-10 23:14:07 +00:00
|
|
|
// Concatenate select2.css onto the admin.css files.
|
|
|
|
concat: {
|
|
|
|
admin: {
|
|
|
|
files: {
|
|
|
|
'<%= dirs.css %>/admin.css' : ['<%= dirs.css %>/select2.css', '<%= dirs.css %>/admin.css'],
|
|
|
|
'<%= dirs.css %>/admin-rtl.css' : ['<%= dirs.css %>/select2.css', '<%= dirs.css %>/admin-rtl.css']
|
|
|
|
}
|
2017-02-16 10:44:43 +00:00
|
|
|
}
|
2017-02-10 23:14:07 +00:00
|
|
|
},
|
|
|
|
|
2014-08-29 21:04:13 +00:00
|
|
|
// Watch changes for assets.
|
2014-02-02 21:33:20 +00:00
|
|
|
watch: {
|
2014-09-22 16:55:53 +00:00
|
|
|
css: {
|
|
|
|
files: ['<%= dirs.css %>/*.scss'],
|
2018-07-19 12:12:12 +00:00
|
|
|
tasks: ['sass', 'rtlcss', 'postcss', 'cssmin', 'concat']
|
2014-02-02 21:33:20 +00:00
|
|
|
},
|
|
|
|
js: {
|
|
|
|
files: [
|
2020-05-05 03:58:58 +00:00
|
|
|
'GruntFile.js',
|
2014-02-02 21:33:20 +00:00
|
|
|
'<%= dirs.js %>/admin/*js',
|
|
|
|
'<%= dirs.js %>/frontend/*js',
|
2014-02-19 19:53:00 +00:00
|
|
|
'!<%= dirs.js %>/admin/*.min.js',
|
2014-07-30 17:23:34 +00:00
|
|
|
'!<%= dirs.js %>/frontend/*.min.js'
|
2014-02-02 21:33:20 +00:00
|
|
|
],
|
2020-05-05 03:52:28 +00:00
|
|
|
tasks: ['eslint','uglify']
|
2014-02-02 21:33:20 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-09-13 21:24:01 +00:00
|
|
|
// PHP Code Sniffer.
|
|
|
|
phpcs: {
|
|
|
|
options: {
|
2017-10-10 16:08:23 +00:00
|
|
|
bin: 'vendor/bin/phpcs'
|
2016-09-13 21:24:01 +00:00
|
|
|
},
|
|
|
|
dist: {
|
|
|
|
src: [
|
2019-01-10 12:01:27 +00:00
|
|
|
'**/*.php', // Include all php files.
|
|
|
|
'!includes/api/legacy/**',
|
|
|
|
'!includes/libraries/**',
|
|
|
|
'!node_modules/**',
|
|
|
|
'!tests/cli/**',
|
|
|
|
'!tmp/**',
|
|
|
|
'!vendor/**'
|
2016-09-13 21:24:01 +00:00
|
|
|
]
|
|
|
|
}
|
2017-04-29 15:23:01 +00:00
|
|
|
},
|
|
|
|
|
2017-05-04 22:29:40 +00:00
|
|
|
// Autoprefixer.
|
2017-05-03 21:41:10 +00:00
|
|
|
postcss: {
|
2017-04-29 15:23:01 +00:00
|
|
|
options: {
|
2017-05-03 21:41:10 +00:00
|
|
|
processors: [
|
2019-07-12 06:52:36 +00:00
|
|
|
require( 'autoprefixer' )
|
2017-04-29 15:23:01 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
dist: {
|
|
|
|
src: [
|
|
|
|
'<%= dirs.css %>/*.css'
|
|
|
|
]
|
|
|
|
}
|
2014-02-10 14:29:41 +00:00
|
|
|
}
|
2014-02-02 19:22:05 +00:00
|
|
|
});
|
2014-01-30 16:11:02 +00:00
|
|
|
|
2018-05-22 12:40:30 +00:00
|
|
|
// Load NPM tasks to be used here.
|
2017-06-26 17:16:46 +00:00
|
|
|
grunt.loadNpmTasks( 'grunt-sass' );
|
|
|
|
grunt.loadNpmTasks( 'grunt-phpcs' );
|
2017-01-20 18:29:48 +00:00
|
|
|
grunt.loadNpmTasks( 'grunt-rtlcss' );
|
2017-06-26 17:16:46 +00:00
|
|
|
grunt.loadNpmTasks( 'grunt-postcss' );
|
|
|
|
grunt.loadNpmTasks( 'grunt-stylelint' );
|
2020-05-05 03:49:29 +00:00
|
|
|
grunt.loadNpmTasks( 'gruntify-eslint' );
|
2014-02-02 20:47:06 +00:00
|
|
|
grunt.loadNpmTasks( 'grunt-contrib-uglify' );
|
2014-09-22 16:55:53 +00:00
|
|
|
grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
|
2017-02-10 23:14:07 +00:00
|
|
|
grunt.loadNpmTasks( 'grunt-contrib-concat' );
|
2019-02-23 01:00:47 +00:00
|
|
|
grunt.loadNpmTasks( 'grunt-contrib-copy' );
|
2014-02-02 21:33:20 +00:00
|
|
|
grunt.loadNpmTasks( 'grunt-contrib-watch' );
|
2014-02-10 12:52:41 +00:00
|
|
|
grunt.loadNpmTasks( 'grunt-contrib-clean' );
|
2014-01-30 16:34:23 +00:00
|
|
|
|
2018-05-22 12:40:30 +00:00
|
|
|
// Register tasks.
|
2014-02-02 20:08:35 +00:00
|
|
|
grunt.registerTask( 'default', [
|
2017-11-21 00:16:24 +00:00
|
|
|
'js',
|
2020-02-05 13:42:49 +00:00
|
|
|
'css'
|
2014-02-02 20:08:35 +00:00
|
|
|
]);
|
|
|
|
|
2016-01-22 19:42:05 +00:00
|
|
|
grunt.registerTask( 'js', [
|
2020-05-05 03:52:28 +00:00
|
|
|
'eslint',
|
2016-01-22 19:42:05 +00:00
|
|
|
'uglify:admin',
|
2019-08-02 17:23:48 +00:00
|
|
|
'uglify:frontend'
|
2016-01-22 19:42:05 +00:00
|
|
|
]);
|
|
|
|
|
2014-09-26 13:00:36 +00:00
|
|
|
grunt.registerTask( 'css', [
|
|
|
|
'sass',
|
2017-01-20 18:29:48 +00:00
|
|
|
'rtlcss',
|
2017-05-04 22:29:40 +00:00
|
|
|
'postcss',
|
2017-02-10 23:14:07 +00:00
|
|
|
'cssmin',
|
2017-05-04 22:29:40 +00:00
|
|
|
'concat'
|
2014-09-26 13:00:36 +00:00
|
|
|
]);
|
|
|
|
|
2019-07-03 09:46:28 +00:00
|
|
|
grunt.registerTask( 'assets', [
|
|
|
|
'js',
|
|
|
|
'css'
|
|
|
|
]);
|
|
|
|
|
2019-07-12 14:28:31 +00:00
|
|
|
grunt.registerTask( 'e2e-build', [
|
|
|
|
'uglify:admin',
|
|
|
|
'uglify:frontend',
|
|
|
|
'uglify:flexslider',
|
|
|
|
'css'
|
|
|
|
]);
|
|
|
|
|
2017-11-21 00:16:24 +00:00
|
|
|
// Only an alias to 'default' task.
|
2014-02-02 20:08:35 +00:00
|
|
|
grunt.registerTask( 'dev', [
|
2017-11-21 00:16:24 +00:00
|
|
|
'default'
|
|
|
|
]);
|
2014-07-30 17:23:34 +00:00
|
|
|
};
|