Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const mix = require('laravel-mix');
- const lodash = require("lodash");
- const fs = require('fs');
- const folder = {
- src: "resources/", // source files
- dist: "public/", // build files
- dist_assets: "public/assets/" //build assets files
- };
- // uglify
- mix.options({
- uglify: {
- uglifyOptions: {
- mangle: {
- keep_fnames: true,
- }
- }
- }
- });
- //done
- // disabling source maps
- mix.sourceMaps(false);
- var third_party_js = [
- "./node_modules/jquery/dist/jquery.js",
- "./node_modules/bootstrap/dist/js/bootstrap.bundle.min.js",
- "./node_modules/simplebar/dist/simplebar.min.js",
- "./node_modules/node-waves/dist/waves.min.js",
- "./node_modules/waypoints/lib/jquery.waypoints.min.js",
- "./node_modules/jquery.counterup/jquery.counterup.min.js",
- "./node_modules/feather-icons/dist/feather.js",
- ];
- //copying required assets
- mix.combine(third_party_js, folder.dist_assets + "js/vendor.js").minify(folder.dist_assets + "js/vendor.js");
- //done
- // // optional third party assets
- var third_party_assets = {
- css_js: [
- {
- "name": "fullcalendar-list",
- "assets": [
- "./node_modules/@fullcalendar/core/main.min.js",
- "./node_modules/@fullcalendar/core/main.min.css",
- "./node_modules/@fullcalendar/bootstrap/main.min.js",
- "./node_modules/@fullcalendar/bootstrap/main.min.css",
- "./node_modules/@fullcalendar/daygrid/main.min.js",
- "./node_modules/@fullcalendar/daygrid/main.min.css",
- "./node_modules/@fullcalendar/timegrid/main.min.js",
- "./node_modules/@fullcalendar/timegrid/main.min.css",
- "./node_modules/@fullcalendar/list/main.min.js",
- "./node_modules/@fullcalendar/list/main.min.css",
- "./node_modules/@fullcalendar/interaction/main.min.js",
- ]
- },
- {
- "name": "apexcharts",
- "assets": [
- "./node_modules/apexcharts/dist/apexcharts.min.js"
- ]
- },
- {
- "name": "bootstrap-datepicker",
- "assets": [
- "./node_modules/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css",
- "./node_modules/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js",
- ]
- },
- {
- "name": "bootstrap-maxlength",
- "assets": [
- "./node_modules/bootstrap-maxlength/dist/bootstrap-maxlength.min.js",
- ]
- },
- {
- "name": "bootstrap-select",
- "assets": [
- "./node_modules/bootstrap-select/dist/css/bootstrap-select.min.css",
- "./node_modules/bootstrap-select/dist/js/bootstrap-select.min.js",
- ]
- },
- {
- "name": "bootstrap-table",
- "assets": [
- "./node_modules/bootstrap-table/dist/bootstrap-table.min.css",
- "./node_modules/bootstrap-table/dist/bootstrap-table.min.js",
- ]
- },
- {
- "name":"daterangepicker",
- "assets": [
- "./node_modules/daterangepicker/daterangepicker.js",
- "./node_modules/daterangepicker/daterangepicker.css",
- ],
- },
- {
- "name": "datatables",
- "assets": [
- "./node_modules/datatables.net/js/jquery.dataTables.min.js",
- "./node_modules/datatables.net-bs4/js/dataTables.bootstrap4.min.js",
- "./node_modules/datatables.net-bs4/css/dataTables.bootstrap4.min.css",
- "./node_modules/datatables.net-responsive/js/dataTables.responsive.min.js",
- "./node_modules/datatables.net-responsive-bs4/js/responsive.bootstrap4.min.js",
- "./node_modules/datatables.net-buttons/js/dataTables.buttons.min.js",
- "./node_modules/datatables.net-buttons-bs4/js/buttons.bootstrap4.min.js",
- "./node_modules/datatables.net-buttons/js/buttons.html5.min.js",
- "./node_modules/datatables.net-buttons/js/buttons.flash.min.js",
- "./node_modules/datatables.net-buttons/js/buttons.print.min.js",
- "./node_modules/datatables.net-keytable/js/dataTables.keyTable.min.js",
- "./node_modules/datatables.net-select/js/dataTables.select.min.js",
- "./node_modules/datatables.net-responsive-bs4/css/responsive.bootstrap4.css",
- "./node_modules/datatables.net-buttons-bs4/css/buttons.bootstrap4.css",
- "./node_modules/datatables.net-select-bs4/css/select.bootstrap4.css",
- ]
- },
- {
- "name": "flatpickr",
- "assets": [
- "./node_modules/flatpickr/dist/flatpickr.min.css",
- "./node_modules/flatpickr/dist/flatpickr.min.js",
- ]
- },
- {
- "name": "jquery-countdown",
- "assets": [
- "./node_modules/jquery-countdown/dist/jquery.countdown.min.js",
- ]
- },
- {
- "name": "jquery-fileupload",
- "assets": [
- "./node_modules/blueimp-file-upload/js/vendor/jquery.ui.widget.js",
- "./node_modules/blueimp-file-upload/js/jquery.fileupload.js",
- "./node_modules/blueimp-file-upload/js/jquery.fileupload-process.js",
- "./node_modules/blueimp-file-upload/js/jquery.fileupload-validate.js",
- "./node_modules/blueimp-file-upload/js/jquery.fileupload-video.js",
- ]
- },
- {
- "name": "jquery-knob",
- "assets": [
- "./node_modules/jquery-knob/dist/jquery.knob.min.js",
- ]
- },
- {
- "name": "jquery-mask-plugin",
- "assets": [
- "./node_modules/jquery-mask-plugin/dist/jquery.mask.min.js",
- ]
- },
- {
- "name": "jquery.flot.tooltip",
- "assets": [
- "./node_modules/jquery.flot.tooltip/js/jquery.flot.tooltip.min.js",
- ]
- },
- {
- "name": "jquery-toast-plugin",
- "assets": [
- "./node_modules/jquery-toast-plugin/dist/jquery.toast.min.js",
- "./node_modules/jquery-toast-plugin/dist/jquery.toast.min.css",
- ]
- },
- {
- "name": "moment",
- "assets": [
- "./node_modules/moment/min/moment.min.js",
- ]
- },
- {
- "name": "moment-timezone",
- "assets": [
- "./node_modules/moment-timezone/builds/moment-timezone-with-data-1970-2030.min.js",
- ]
- },
- {
- "name": "parsleyjs",
- "assets": [
- "./node_modules/parsleyjs/dist/parsley.min.js",
- ]
- },
- {
- "name": "run",
- "assets": [
- "./node_modules/run/run.js",
- ]
- },
- {
- "name": "select2",
- "assets": [
- "./node_modules/select2/dist/js/select2.min.js",
- "./node_modules/select2/dist/css/select2.min.css",
- ]
- },
- {
- "name": "simplebar",
- "assets": [
- "./node_modules/simplebar/dist/simplebar.min.js",
- "./node_modules/simplebar/dist/simplebar.min.css",
- ]
- },
- {
- "name": "sweetalert2",
- "assets": [
- "./node_modules/sweetalert2/dist/sweetalert2.min.js",
- "./node_modules/sweetalert2/dist/sweetalert2.min.css",
- ]
- },
- {
- "name": "tippy.js",
- "assets": [
- "./node_modules/tippy.js/dist/tippy.all.min.js",
- ]
- },
- {
- "name": "bootstrap-daterangepicker",
- "assets": [
- "./node_modules/bootstrap-daterangepicker/daterangepicker.js",
- "./node_modules/bootstrap-daterangepicker/daterangepicker.css",
- ]
- },
- {
- "name": "twitter-bootstrap-wizard",
- "assets": [
- "./node_modules/twitter-bootstrap-wizard/jquery.bootstrap.wizard.min.js"
- ]
- },
- {
- "name": "jquery-validation",
- "assets": [
- "./node_modules/jquery-validation/dist/jquery.validate.min.js"
- ]
- }
- ]
- };
- //copying third party assets
- lodash(third_party_assets).forEach(function (assets, type) {
- if (type === "css_js") {
- lodash(assets).forEach(function (plugin) {
- var name = plugin['name'],
- assetlist = plugin['assets'],
- css = [],
- js = [];
- lodash(assetlist).forEach(function (asset) {
- var ass = asset.split(',');
- for (let i = 0; i < ass.length; ++i) {
- if (ass[i].substr(ass[i].length - 3) === ".js") {
- js.push(ass[i]);
- } else {
- css.push(ass[i]);
- }
- }
- });
- if (js.length > 0) {
- mix.combine(js, folder.dist_assets + "/libs/" + name + "/" + name + ".min.js");
- }
- if (css.length > 0) {
- mix.combine(css, folder.dist_assets + "/libs/" + name + "/" + name + ".min.css");
- }
- });
- }
- });
- // copy all fonts -
- var out = folder.dist_assets + "fonts";
- mix.copy(folder.src + "fonts/", out);
- // copy all images -
- out = folder.dist_assets + "images";
- mix.copy(folder.src + "images/", out);
- // scss
- var getFiles = function (dir) {
- // get all 'files' in this directory
- // filter directories
- return fs.readdirSync(dir).filter(file => {
- return fs.statSync(`${dir}/${file}`).isFile();
- });
- };
- // compile scss
- getFiles(folder.src + "scss").forEach(function (filepath) {
- var fileName = filepath.substring(0, filepath.lastIndexOf('.')) || filepath;
- mix.sass(folder.src + "scss/" + filepath, folder.dist_assets + "css").options({processCssUrls: mix.inProduction()}).minify(folder.dist_assets + "css/" + fileName + ".css").version();
- });
- //copying code js pages related assets
- getFiles(folder.src + "js/pages").forEach(function (filepath) {
- mix.js(folder.src + "js/pages/" + filepath, folder.dist_assets + "js/pages/" + filepath).version();
- });
- // app theme file
- mix.combine([folder.src + 'js/layout.js', folder.src + 'js/app.js', folder.src + 'js/checkout.js'], folder.dist_assets + "js/app.js")
- .minify(folder.dist_assets + "js/app.js").version();
- // copy pdf
- mix.copy(folder.src + 'pdf', folder.dist_assets + 'pdf');
- // app vue
- // mix.js(folder.src + 'js/app_vue.js', folder.dist_assets + "js/app_vue.js").vue();
Advertisement
Add Comment
Please, Sign In to add comment