{"_id":"@clarivate/webpack-merge-and-include-globally","_rev":"6-28748b885ee55016e5e77483c1357b1e","name":"@clarivate/webpack-merge-and-include-globally","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.2":{"name":"@clarivate/webpack-merge-and-include-globally","version":"1.0.2","keywords":["webpack","global","js","merge","concat","global library","expose"],"author":{"name":"Mark Shapiro"},"license":"MIT","_id":"@clarivate/webpack-merge-and-include-globally@1.0.2","maintainers":[{"name":"slargemain","email":"stephane.largemain@clarivate.com"},{"name":"pravinsharma","email":"praveenkumar.sharma@clarivate.com"},{"name":"keithdimatteo","email":"keith.dimatteo@gmail.com"},{"name":"mohanraj.pushparaj","email":"mohanraj.pushparaj@Clarivate.com"}],"contributors":[],"homepage":"https://github.com/slargemain/webpack-merge-and-include-globally#readme","bugs":{"url":"https://github.com/slargemain/webpack-merge-and-include-globally/issues"},"dist":{"shasum":"69b0e3949eecf75b2cc296fe6ed5de9419a195d9","tarball":"https://registry.npmjs.org/@clarivate/webpack-merge-and-include-globally/-/webpack-merge-and-include-globally-1.0.2.tgz","fileCount":15,"integrity":"sha512-LhL+ALiuEu7ikjF+eK5DOkanIMi6ODwgRslmOsvKT3d0KnfVoo1lctwjlThN/dBZdeOoe0jT9tcFIXkHCVMGgQ==","signatures":[{"sig":"MEUCIB8o00nCKiYTR3dlXH8X7svJHr3erxGKEBJswg2UUOlaAiEA2Sul19rdt3bFsDP4gtwonTWhM0xe7JXOSKLYZMO1Rb8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":37523,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh2C0MCRA9TVsSAnZWagAAWvgQAIe5u4pR3YwkW7cXUfBu\n+Stg5Cu7/6sbreTVSHQMhEUKbuUPJtZ/THPsW6+7CTtWCmsxof2RpLqnTyWh\npmSJ5p1IRfY0JMTaR4AnQUIn47SfhgO7h2qIyelaNhnj1LZNNSMCwxHLLJXv\nFWxuDm6JYjvVig897ztKiIpXh457pMR1Ua1f4+MmLsWe47lFfsh6ocZ0z9HD\n0jNs3M299kIzLC1TvXFQDrhjdn++wv6qdaiItjhUP9XnGQpyvtnXZxUaxzmo\nYLFIMAhWLzkKdV8lwak9runTLNO0ZFSs9iy6UjVLh9duWTpwuZJjsvREjcKo\nH1gD14pWkolpHJIPndVAF4OAB+CqGpFSRSJ2HIM9cXOU+UP3l9KjJXmMXbCa\nrgGv/pGDvvCVU/hM7iv9iLrW5Wt+OzVT5Xx70bMISBKzVHyxIUXK9AxFmflm\ns26v7dhzmLPNTfSbnfdAHfbns2Yi7atRomL6SnJTVd69abdJ4Xyv0PR+8jRh\nkw55wLSem09nbqcwirXupJWy4zkiD/zri5Wz2BuLsDGGG9gPjhE+YhWqD65m\nVRGfTp02T7nTD6euS/QpmtZGgHRS0pyDxGKMZ8BDT5lul+n6NWn5B+UC6uJE\ns/OvBP9kY1QRaRyNTkvwVfzTr6vohoGP7zgRrGPilAco3+qbkqBYdOmev4QY\ntd+g\r\n=Auc3\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","gitHead":"2925e4e4f3137c0250651042fe017a516b1c1a05","scripts":{"lint":"eslint index.js index.test.js webpack.config.js --fix","test":"jest","build":"webpack --progress && cp example/index.html dist/index.html","start":"webpack serve","build-src":"babel index.js --out-file index.node6-compatible.js"},"_npmUser":{"name":"slargemain","email":"stephane.largemain@clarivate.com"},"repository":{"url":"git+https://github.com/slargemain/webpack-merge-and-include-globally.git","type":"git"},"_npmVersion":"6.14.15","description":"Merge multiple files (js,css..) into single file to include somewhere","directories":{},"_nodeVersion":"14.18.1","dependencies":{"glob":"^7.1.6","rev-hash":"^3.0.0","es6-promisify":"^6.1.1"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.6.3","humps":"^2.0.1","eslint":"^7.16.0","jquery":"^3.5.1","install":"^0.13.0","webpack":"^5.11.1","clean-css":"^4.2.3","uglify-js":"^3.12.3","@babel/cli":"^7.12.10","babel-core":"^7.0.0-bridge.0","babel-jest":"^26.6.3","classnames":"^2.2.6","raw-loader":"^4.0.2","@babel/core":"^7.12.10","webpack-cli":"4.3.0","babel-eslint":"^10.1.0","babel-loader":"^8.2.2","@babel/preset-env":"^7.12.11","eslint-plugin-jest":"^24.1.3","webpack-dev-server":"^3.11.1","eslint-plugin-import":"^2.22.1","eslint-config-airbnb-base":"^14.2.1","@babel/plugin-transform-runtime":"7.12.10"},"peerDependencies":{"webpack":">=1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/webpack-merge-and-include-globally_1.0.2_1634284435789_0.656646851151562","host":"s3://npm-registry-packages"}}},"time":{"created":"2021-10-15T07:53:55.731Z","modified":"2025-11-24T09:15:08.876Z","1.0.2":"2021-10-15T07:53:56.007Z"},"bugs":{"url":"https://github.com/slargemain/webpack-merge-and-include-globally/issues"},"author":{"name":"Mark Shapiro"},"license":"MIT","homepage":"https://github.com/slargemain/webpack-merge-and-include-globally#readme","keywords":["webpack","global","js","merge","concat","global library","expose"],"repository":{"url":"git+https://github.com/slargemain/webpack-merge-and-include-globally.git","type":"git"},"description":"Merge multiple files (js,css..) into single file to include somewhere","contributors":[],"maintainers":[{"email":"praveenkumar.sharma@clarivate.com","name":"pravinsharma"},{"email":"mohanraj.pushparaj@Clarivate.com","name":"mohanraj.pushparaj"},{"email":"stephane.largemain@clarivate.com","name":"slargemain"},{"email":"jordi.bellido+npmjs@clarivate.com","name":"jordi-bellido_clv"},{"email":"sebastien.dubuc@clarivate.com","name":"sebastien.dubuc.clarivate"}],"readme":"# MERGE INTO SINGLE FILE PLUGIN FOR WEBPACK\r\n\r\nWebpack plugin to merge your source files together into single file, to be included in index.html, and achieving same effect as you would by including them all separately through `<script>` or `<link>`.\r\n\r\n### Getting Started\r\n\r\n```bash\r\nnpm install --save-dev webpack-merge-and-include-globally\r\n```\r\n\r\n### Usage\r\n\r\nLets say you want to make libraries like `jquery`, `moment` (including 3 languages) and `toastr` available globally, and you're struggling to make them global with webpack or just importing them (in cases they aren't written well) because require() wraps the code into new scope and you want to execute it against a global scope, and you don't want to do this:\r\n```html\r\n  <script src=\"/node_modules/jquery/dist/jquery.min.js\"></script>\r\n  <script src=\"/node_modules/moment/moment.js\"></script>\r\n  <script src=\"/node_modules/moment/locale/cs.js\"></script>\r\n  <script src=\"/node_modules/moment/locale/de.js\"></script>\r\n  <script src=\"/node_modules/moment/locale/nl.js\"></script>\r\n  <script src=\"/node_modules/toastr/build/toastr.min.js\"></script>\r\n  \r\n  <link rel=\"stylesheet\" href=\"/node_modules/toastr/build/toastr.min.css\">\r\n```\r\nbecause your `node_modules` is not available in production.\r\n<br/>with this plugin you can achieve the desired effect this way:\r\n```javascript\r\n\r\n  const MergeIntoSingleFilePlugin = require('webpack-merge-and-include-globally');\r\n  \r\n  module.exports = {\r\n    ...\r\n    plugins: [\r\n        new MergeIntoSingleFilePlugin({\r\n            files: {\r\n                \"vendor.js\": [\r\n                    'node_modules/jquery/dist/jquery.min.js',\r\n                    //  will work too\r\n                    //  'node_modules/jquery/**/*.min.js',\r\n                    'node_modules/moment/moment.js',\r\n                    'node_modules/moment/locale/cs.js',\r\n                    'node_modules/moment/locale/de.js',\r\n                    'node_modules/moment/locale/nl.js',\r\n                    'node_modules/toastr/build/toastr.min.js'\r\n                ],\r\n                \"vendor.css\": [\r\n                    'node_modules/toastr/build/toastr.min.css'\r\n                ]\r\n            }\r\n        }),\r\n    ]\r\n\r\n```\r\nthis generates 2 files with merged js and css content, include them into your `index.html` to take effect:\r\n``` html\r\n  <script src=\"./vendor.js\"></script>\r\n  <link rel=\"stylesheet\" href=\"./vendor.css\">\r\n```\r\nnow `jQuery`, `moment` and `toastr` are available globally throughout your application.\r\n\r\n### Options\r\n\r\n#### files (as object)\r\n\r\nObject that maps file names to array of all files (can also be defined by wildcard path) that will be merged together and saved under each file name.\r\n<br/>For example to merge `jquery`, `classnames` and `humps` into `vendor.js`, do:\r\n```javascript\r\nnew MergeIntoSingle({\r\n  files: {\r\n    'vendor.js': [\r\n      'node_modules/jquery/**/*.min.js',\r\n      'node_modules/classnames/index.js',\r\n      'node_modules/humps/humps.js'\r\n    ],\r\n    'style.css': [\r\n      'example/test.css'\r\n    ]\r\n  }\r\n})\r\n```\r\n\r\n#### transform\r\n\r\nObject that maps resulting file names to tranform methods that will be applied on merged content before saving. Use to minify / uglify the result.\r\n<br/>For example to minify the final merge result of `vendor.js`, do:\r\n```javascript\r\nnew MergeIntoSingle({\r\n  files: { 'vendor.js': [...] },\r\n  transform: {\r\n    'vendor.js': code => require(\"uglify-js\").minify(code).code\r\n  }\r\n})\r\n```\r\n\r\n#### files (as array)\r\n\r\nAlternative way to specify files as array of `src` & `dest`, for flexibility to transform and create multiple destination files for same source when you need to generate additional map file for example.\r\n```javascript\r\nnew MergeIntoSingle({\r\n  files: [{\r\n    src:[\r\n      'node_modules/jquery/**/*.min.js',\r\n      'node_modules/classnames/index.js',\r\n      'node_modules/humps/humps.js'\r\n    ],\r\n    dest: code => {\r\n      const min = uglifyJS.minify(code, {sourceMap: {\r\n        filename: 'vendor.js',\r\n        url: 'vendor.js.map'\r\n      }});\r\n      return {\r\n        'vendor.js':min.code,\r\n        'vendor.js.map': min.map\r\n      }\r\n    },\r\n\r\n    // also possible:\r\n    //\r\n    // dest: 'vendor.js'\r\n  },{\r\n    src: ['example/test.css'],\r\n    dest: 'style.css'\r\n\r\n    // also possible:\r\n    //\r\n    // dest: code => ({\r\n    //   'style.css':new CleanCSS({}).minify(code).styles\r\n    // })\r\n  }]\r\n})\r\n```\r\n\r\n#### hash\r\ndefault: false\r\n\r\nset `true` to append version hash before file extension.\r\n\r\nyou can get names of generated files mapped to original by passing callback function as second argument to plugin: \r\n```javascript\r\nnew MergeIntoSingle({ ... }, filesMap => { ... }),\r\n```\r\n\r\n#### transformFileName\r\ndefault: undefined\r\n\r\nalso you can pass function for change output file name with hash\r\n```javascript\r\nnew MergeIntoSingle({\r\n  ...,\r\n  transformFileName: (fileNameBase, extension, hash) => `${fileName}.[${hash}]${extension}`,\r\n  // bundle.[somehash].js\r\n}),\r\n\r\n//or\r\n\r\nnew MergeIntoSingle({\r\n  ...,\r\n  transformFileName: (fileNameBase, extension, hash) => `${fileNameBase}${extension}?hash=${hash}`,\r\n  // bundle.js?hash=somehash\r\n}),\r\n\r\n```\r\n\r\n#### encoding\r\n\r\ndefault: 'utf-8'\r\n\r\nencoding of node.js reading\r\n\r\n#### chunks\r\n\r\ndefault: undefined\r\n\r\narray of entry points (strings) for which this plugin should run only\r\n\r\n#### separator\r\n\r\ndefault: '\\n'\r\n\r\nstring used between files when joining them together\r\n\r\n### Working Example\r\n\r\nworking example already included in project.\r\n<br/>to test first install `npm i`, then run `npm run start` to see it in action\r\n<br/>and `npm run build` to build prod files with vendor file and `index.html`.\r\n","readmeFilename":"README.md"}