{"id":16173250,"url":"https://github.com/eiskalteschatten/concatenate-js-middleware","last_synced_at":"2026-05-12T07:41:11.666Z","repository":{"id":57205110,"uuid":"114622576","full_name":"eiskalteschatten/concatenate-js-middleware","owner":"eiskalteschatten","description":"A module to concatenate JavaScript files on-the-fly or to save them to disk.","archived":false,"fork":false,"pushed_at":"2018-07-26T22:06:35.000Z","size":5,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-14T02:40:25.313Z","etag":null,"topics":["concat","concatenation","express","express-middleware","javascript","nodejs","nodemodules"],"latest_commit_sha":null,"homepage":"https://www.alexseifert.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eiskalteschatten.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-18T09:38:36.000Z","updated_at":"2020-09-08T20:58:59.000Z","dependencies_parsed_at":"2022-09-18T00:50:44.245Z","dependency_job_id":null,"html_url":"https://github.com/eiskalteschatten/concatenate-js-middleware","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eiskalteschatten%2Fconcatenate-js-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eiskalteschatten%2Fconcatenate-js-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eiskalteschatten%2Fconcatenate-js-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eiskalteschatten%2Fconcatenate-js-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eiskalteschatten","download_url":"https://codeload.github.com/eiskalteschatten/concatenate-js-middleware/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247623005,"owners_count":20968574,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["concat","concatenation","express","express-middleware","javascript","nodejs","nodemodules"],"created_at":"2024-10-10T04:07:39.027Z","updated_at":"2026-05-12T07:41:06.647Z","avatar_url":"https://github.com/eiskalteschatten.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# concatenate-js-middleware\n\n\u003e A module to concatenate JavaScript files on-the-fly or to save them to disk.\n\n*This module is still in its infancy. More documentation and features will be added as it matures.*\n\n## Requirements\n\nThis module is tested with Node.js 8 and 9. It might work with Node.js 6 or 7, but is not tested.\n\n## Install\n\n```\nnpm install --save concatenate-js-middleware\n```\n\n## Config\n\nIn order to concatenate your JavaScript files, you will need to configure which JavaScript files will be concatenated into which files. In the example below, we have two final JavaScript files: \"libs.js\" and \"scripts.js\":\n\n- \"libs.js\" contains the files \"../../node_modules/jquery/dist/jquery.min.js\" and \"other/lib.js\".\n- \"script.js\" contains the files \"../public/js/homepage.js\" and \"../public/js/anotherFile.js\".\n\n**jsConfig.js**\n\n```js\n'use strict';\n\nconst path = require('path');\n\nconst libs = [\n  '../../node_modules/jquery/dist/jquery.min.js',\n  'other/lib.js'\n];\n\nconst scripts = [\n  '../public/js/homepage.js',\n  '../public/js/anotherFile.js'\n];\n\nmodule.exports = {\n  libs: libs.map(file =\u003e {\n    return path.join(__dirname, file);\n  }),\n  scripts: scripts.map(file =\u003e {\n    return path.join(__dirname, file);\n  })\n};\n```\n\n## Usage\n\n### For on-the-fly compiling\n\n```js\nconst concatenateJs = require('concatenate-js-middleware');\nconst jsConfig = require('./config/jsConfig.js');\n\napp.use('/js/:jsName', concatenateJs(jsConfig));\n```\n\n### For concatenating and saving as static JavaScript file\n\n```js\nconst concatenateJs = require('concatenate-js-middleware');\nconst jsConfig = require('./config/jsConfig.js');\n\nconcatenateJs.concatenateJsAndSaveMultiple({\n  originPath: path.join(__dirname, 'public/js/'),\n  destinationPath: path.join(__dirname, 'public/js/'),\n  files: ['libs.js'],\n  minify: true,\n  config: jsConfig\n}).then(...).catch(...);\n```\n\n\n## API\n\n### concatenateJs()\n\nReturns the concatenated JavaScript as a string.\n\n```js\nconst concatenateJs = require('concatenate-js-middleware');\nconst jsConfig = require('./config/jsConfig.js');\n\nconst jsString = concatenateJs.concatenateJs(jsConfig['libs']).then(...).catch(...);\n```\n\n### concatenateJsAndSave()\n\nConcatenates the given JavaScript file.\n\n```js\nconst concatenateJs = require('concatenate-js-middleware');\nconst jsConfig = require('./config/jsConfig.js');\n\nconcatenateJs.concatenateJsAndSave({\n  originPath: path.join(__dirname, 'public/js/'),\n  destinationPath: path.join(__dirname, 'public/js/'),\n  file: 'libs.js',\n  minify: true,\n  config: jsConfig\n}).then(...).catch(...);\n```\n\n\n### concatenateJsAndSaveMultiple()\n\nConcatenates multiple JavaScript files defined in the \"files\" option.\n\n```js\nconst concatenateJs = require('concatenate-js-middleware');\nconst jsConfig = require('./config/jsConfig.js');\n\nconcatenateJs.concatenateJsAndSaveMultiple({\n  originPath: path.join(__dirname, 'public/js/'),\n  destinationPath: path.join(__dirname, 'public/js/'),\n  files: ['libs.js'],\n  minify: true,\n  config: jsConfig\n}).then(...).catch(...);\n```\n\n### setupCleanupOnExit()\n\nDeletes the passed directory when the app is exited. The idea is to pass the directory where your compiled CSS files are, so that they can be deleted when the app is exited and recompiled when the app starts.\n\n```js\nconst concatenateJs = require('concatenate-js-middleware');\n\nprocess.on('SIGINT', () =\u003e {\n  try {\n    concatenateJs.setupCleanupOnExit({\n      path: path.join(__dirname, 'public/js/'),\n      files: ['libs.js']\n    });\n    process.exit(0);\n  }\n  catch(error) {\n    process.exit(1);\n  }\n});\n```\n\n\n## Maintainer\n\nThis modules is maintained by Alex Seifert ([Website](https://www.alexseifert.com), [Github](https://github.com/eiskalteschatten)).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feiskalteschatten%2Fconcatenate-js-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feiskalteschatten%2Fconcatenate-js-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feiskalteschatten%2Fconcatenate-js-middleware/lists"}