Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/queuepro/node_modules/glightbox/development/ drwxrwxr-x | |
| Viewing file: Select action/file-type: const fs = require('fs');
const chokidar = require('chokidar');
const path = require('path');
const notify = require('./notifications');
const jscompiler = require('./jscompiler');
const postcssCompiler = require('./postcss');
const terser = require('terser');
let config = {
js: {
src: 'src/js',
dest: 'dist/js',
},
css: {
src: 'src/postcss',
dest: 'dist/css',
}
};
/**
* Handle Javascript files
* compile the javascript files
* to es2015, minify and sync the files
*
* @param {string} file path
*/
async function handleJavascript(file) {
file = path.join(config.js.src, 'glightbox.js');
const name = path.basename(file);
const res = await jscompiler({
file,
dest: config.js.dest,
format: 'umd',
sourcemap: false,
moduleID: 'GLightbox'
}).catch(error => console.log(error));
if (!res) {
notify('Build Error', `View logs for more info`);
console.log(res)
return false;
}
const minName = name.replace('.js', '.min.js');
const processed = path.join(config.js.dest, name);
const code = fs.readFileSync(processed, 'utf8');
const minified = terser.minify(code);
const minifyPath = path.join(config.js.dest, minName);
fs.writeFileSync(minifyPath, minified.code);
notify('Javascript Build', `Compiled and Minified ${name}`);
}
/**
* Handle Postcss files
* compile the css files
*
* @param {string} file path
*/
async function handlePostCSS(file) {
const name = path.basename(file);
const dest = config.css.dest;
let res = await postcssCompiler({
file,
dest,
minify: true
}).catch(error => console.log(error));
if (!res) {
return false;
}
notify('PostCSS Build', `Compiled and Minified ${name}`);
}
/**
* Watcher
* what the files for the backedn
* this includes js and css files
*/
function filesWatcher() {
const watcher = chokidar.watch(['src'], {
ignored: ['.DS_Store', 'src/js/.jshintrc', 'src/js/.babelrc'],
persistent: true,
depth: 3,
awaitWriteFinish: {
stabilityThreshold: 500,
pollInterval: 500
},
});
watcher.on('change', path => {
if (path.endsWith('.js')) {
return handleJavascript(path);
}
if (path.endsWith('.css')) {
return handlePostCSS(path);
}
})
watcher.on('ready', () => notify('Watching files', 'Initial scan complete. Ready for changes'))
}
filesWatcher();
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0049 ]-- |