|
'use strict'; |
|
module.exports = function(grunt) { |
|
|
|
grunt.initConfig({ |
|
|
|
// ------- configuration ------- ## |
|
|
|
// common SCSS root for easier SCSS @use / @forward / @incuse usage ## |
|
includePaths: [ |
|
'./library/theme/scss/' // common SCSS root ## |
|
], |
|
|
|
// sass controller file ## |
|
src: 'library/theme/scss/q.scss.theme.scss', |
|
|
|
// main destination file ## |
|
dest: 'library/theme/css/q.scss.theme.css', |
|
|
|
// minified destination file ## |
|
dest_min: 'library/theme/css/q.scss.theme.min.css', |
|
|
|
// object of files to clean up pre-compile ## |
|
clean_dest: [ |
|
'library/theme/css/q.scss.*.css', // regex to find all generated css files ## |
|
'library/theme/css/q.scss.*.map', // regex to find all generated map files ## |
|
], |
|
|
|
// scss files to watch ## |
|
watch_scss: [ |
|
'library/theme/scss/view/*.scss', // regex to track all Template files ## |
|
'library/theme/scss/ui/*.scss', // regex to track all UI files ## |
|
'library/theme/scss/q/*.scss', // regex to track all config files ## |
|
'library/theme/scss/bootstrap/*.scss', // regex to track ,main Bootstrap include ## |
|
], |
|
|
|
// php files to watch ## |
|
watch_php: [ |
|
'library/theme/view/*.php', // main view [template] folder ## |
|
'library/theme/ui/*.php' // ui folder ## |
|
], |
|
|
|
// ------- end config ------- ## |
|
|
|
// clean up old compilled files ## |
|
'clean': { |
|
'dist': |
|
'<%= clean_dest %>' |
|
}, |
|
|
|
// SASS compiller ## |
|
'dart-sass': { |
|
'target': { |
|
'options': { |
|
'outputStyle' : 'expanded', |
|
'sourceMap' : true, |
|
'includePaths' : '<%= includePaths %>', |
|
'lineNumber' : true, |
|
}, |
|
'files': { |
|
'<%= dest %>': '<%= src %>' |
|
} |
|
} |
|
}, |
|
|
|
// watch task ## |
|
'watch': { |
|
// track changes to scss src files ## |
|
'sass': { |
|
'options': { |
|
'livereload': 1337, // dedicated port for live reload ## |
|
}, |
|
'files': |
|
'<%= watch_scss %>' |
|
, |
|
'tasks': [ |
|
'default', // post processing formating ## |
|
] |
|
}, |
|
// track changes to specific PHP templates ## |
|
'php': { |
|
'options': { |
|
'livereload': 1337, |
|
}, |
|
'files': |
|
'<%= watch_php %>' |
|
, |
|
'tasks': [ |
|
'php' // no tasks yet ## |
|
] |
|
}, |
|
}, |
|
|
|
// post processing formating ## |
|
'postcss': { |
|
'options': { |
|
'map': true, // inline sourcemaps |
|
'processors': [ |
|
// add fallbacks for rem units ## |
|
require('pixrem')(), |
|
// add vendor prefixes -- options defined in package.json 'browserslist' ## |
|
require('autoprefixer')(), |
|
] |
|
}, |
|
'dist': { |
|
'src': '<%= dest %>', |
|
'dest': '<%= dest %>', |
|
}, |
|
'minify': { |
|
'options': { |
|
'processors': [ |
|
require('cssnano')() // minifies ## |
|
] |
|
}, |
|
'src': '<%= dest %>', |
|
'dest': '<%= dest_min %>', |
|
} |
|
}, |
|
|
|
}); |
|
|
|
// Load Tasks ## |
|
grunt.loadNpmTasks('grunt-contrib-clean'); // Clean up Tasks ## |
|
grunt.loadNpmTasks('grunt-contrib-watch'); // Watcher ## |
|
grunt.loadNpmTasks('grunt-postcss'); // Post Processing ## |
|
grunt.loadNpmTasks('grunt-dart-sass'); // DART SASS ## |
|
|
|
// Register Tasks ## |
|
grunt.registerTask( 'default', [ |
|
'clean', // clean up old compilled files ## |
|
'dart-sass', // Dart SASS ## |
|
'postcss', // post processing formating ## ## |
|
]); |
|
|
|
// Watch Task ## |
|
grunt.registerTask( 'php', [ |
|
// No specific tasks, just live reload ## |
|
]); |
|
|
|
}; |