[
  {
    "path": ".eslintrc.js",
    "content": "module.exports = {\n    \"env\": {\n        \"es6\": true,\n        \"node\": true\n    },\n    \"extends\": \"eslint:recommended\",\n    \"parserOptions\": {\n        \"ecmaVersion\": 2017\n    },\n    \"rules\": {\n        \"indent\": [\n            \"error\",\n            4\n        ],\n        \"linebreak-style\": [\n            \"error\",\n            \"unix\"\n        ],\n        \"quotes\": [\n            \"error\",\n            \"single\"\n        ],\n        \"semi\": [\n            \"error\",\n            \"always\"\n        ],\n        \"no-console\": \"off\",\n    }\n};"
  },
  {
    "path": ".github/FUNDING.yml",
    "content": "github: [elwin013]\n"
  },
  {
    "path": ".gitignore",
    "content": "node_modules\n.vscode\n.idea"
  },
  {
    "path": ".npmignore",
    "content": "examples\nnode_modules\n.vscode\n.idea\n"
  },
  {
    "path": ".npmrc",
    "content": "sign-git-tag=true\nsign-git-commit=true\n"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2018-2020 Kamil Banach <kontakt@elwin013.com>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE."
  },
  {
    "path": "README.md",
    "content": "# parcel-plugin-static-files-copy\n\nParcelJS plugin to copy static files from some directory to directory with bundle.\n\n### Looking for the ParcelV2 plugin? Check out [parcel-reporter-static-files-copy](https://github.com/elwin013/parcel-reporter-static-files-copy)\n\n## Install\n\n```\nyarn add parcel-plugin-static-files-copy --dev\n```\n\n```\nnpm install -D parcel-plugin-static-files-copy\n```\n\n## Usage\n\n1. Create `static` directory in you project root.\n2. Fill it with your static files\n3. Run build - and that's all!\n\n## Customization\n\nBeyond the default settings, you can:\n\n1. Name of the directory to be copied.\n2. Copy single files.\n3. Copy multiple directories.\n4. Copy from a different directory based on different output directory.\n5. Watch for changes during development (rebuilding when necessary).\n6. Exclude paths from copying.\n\n### Example\n\nThe following configures the plugin to copy all files in `public` to the build directory and watch for changes \nin all source files (`**` is a deep wildcard).\n\n```json\n// package.json\n{\n\t...\n    \"staticFiles\": {\n        \"staticPath\": \"public\",\n        \"watcherGlob\": \"**\"\n    }\n}\n```\n\n### Multiple Static Directories\n\nTo copy more than one directory to the build directory, specify `staticPath` as an array. The following copies \n`public` and `vendor/public`:\n\n```json\n// package.json\n{\n\t...\n    \"staticFiles\": {\n        \"staticPath\": [\"public\", \"vendor/public\"]\n    }\n}\n```\n\n### Copying single files\n\nTo copy single file (instead of content of directory) just pass path to a file instead of directory.  \n\n```json\n// package.json\n{\n\t...\n    \"staticFiles\": {\n        \"staticPath\": [\"path/to/a/file.txt\"]\n    }\n}\n```\n\n### Different source of static files based on output directory\n\nTo copy different files (from different directories) based on output directory (e.g. `--out-dir dist1` and `--out-dir dist2`) \nmake `staticPath` a object:\n\n```json\n// package.json\n{\n    ...\n    \"staticFiles\": {\n        \"staticPath\": [\n            {\n                \"outDirPattern\": \"**/dist1\",\n                \"staticPath\": \"static1\"\n            },\n            {\n                \"outDirPattern\": \"**/dist2\",\n                \"staticPath\": \"static2\"\n            }\n        ]\n  },\n}\n```\n\n### Specify directory to copy static files into\n\nIf you want your files from `staticPath` to get copied into a subdirectory inside the parcel `--out-dir`, make \n`staticPath` an object with `staticOutDir` key:\n\n```json\n// package.json\n{\n    ...\n    \"staticFiles\": {\n        \"staticPath\": [\n            {\n                \"staticPath\": \"static1\",\n                \"staticOutDir\": \"vendor\"\n            }\n        ]\n  },\n}\n```\n\nCopies files from `static1` into the `vendor` directory inside the `--out-dir`.\n\n### Watching for Changes\n\nParcel can rebuild your bundle(s) whenever changes occur in the static directory. This is disabled by default, but it \ncan be enabled by specifying a glob pattern for files that should be watched.\n\nNote the relative file path is used in matching (not just the file name). To match filenames in deep directories, \nstart with a \"globstar\" (double star). The plugin uses Node's built-in [Minimatch Library](https://github.com/isaacs/minimatch) \nfor glob matching.\n\nThe following watches all XML files in the static directory:\n\n```json\n// package.json\n{\n    ...\n    \"staticFiles\": {\n        \"staticPath\": \"public\",\n        \"watcherGlob\": \"**/*.xml\"\n    }\n}\n```\n\nTo disable watching, either remove the `\"watcherGlob\"` key (disabled is the default) or set it to false/null/undefined:\n\n```json\n// package.json\n{\n    ...\n    \"staticFiles\": {\n        \"staticPath\": \"public\",\n        \"watcherGlob\": false\n    }\n}\n```\n\n### Excluding paths\n\nYou can exclude files and directories in your `staticPath` from getting copied to the `outDir` by specifying `excludeGlob`:\n\n```json\n// package.json\n{\n    ...\n    \"staticFiles\": {\n        \"staticPath\": \"public\",\n        \"excludeGlob\": \"**/*.md\"\n    }\n}\n```\n\nExcludes all `.md` files in the `public` path from getting copied.\n\n\nMultiple `excludeGlob`s are possible by specifying it as array:\n\n```json\n// package.json\n{\n\t...\n    \"staticFiles\": {\n        \"staticPath\": \"public\",\n        \"excludeGlob\": [\"docs\", \"docs/**\"]\n    }\n}\n```\n\nExcludes the `docs` directory and all files inside the `docs` directory from getting copied.\n\n\n### Including paths\n\nYou can use the `excludeGlob` and negate it to achieve including behavior:\n\n\n```json\n// package.json\n{\n    ...\n    \"staticFiles\": {\n        \"staticPath\": \"src\",\n        \"excludeGlob\": \"**/!(locales)/*.+(!(txt)|!(json))\"\n    }\n}\n```\n\nIncludes only files from `locales` directory with `.txt` or `.json` extension.\n\n\n### Minimatch glob options\n\nPassing [options into minimatch](https://github.com/isaacs/minimatch#options) to change `watcherGlob` and `excludeGlob` \nbehavior is possible by specifying a `globOptions` object:\n\n```json\n// package.json\n{\n    ...\n    \"staticFiles\": {\n        \"staticPath\": \"public\",\n        \"excludeGlob\": [\"test\", \"test/**\"],\n        \"globOptions\": {\n            \"dot\": true\n        }\n    }\n}\n```\n\nExcludes the `test` directory and all files inside the `test` directory, including files starting with a dot, from \ngetting copied.\n\n### Dev and production config using NODE_ENV\n\nYou can use `env` parameter in `staticPath` object to select static path used in environment chosen by passing `NODE_ENV`:\n\n```json\n// package.json\n{\n    ...\n      \"scripts\": {\n        \"build:dev\": \"NODE_ENV=dev parcel build src/index.html\",\n        \"build:prod\": \"NODE_ENV=prod parcel build src/index.html\"\n      },\n    ...\n      \"staticFiles\": {\n        \"staticPath\": [\n          {\n            \"staticPath\": \"static-dev\",\n            \"env\": \"dev\"\n          },\n          {\n            \"staticPath\": \"static-prod\",\n            \"env\": \"prod\"\n          }\n        ]\n      }\n}\n```\n\nThen running:\n* `build:dev` will copy files from `static-dev` only,\n* `build:prod` will copy files from `static-prod` only.\n\nYou can specify from zero to many static paths per environment.\n\n### Additional examples\n\nCheck [examples](https://github.com/elwin013/parcel-plugin-static-files-copy/tree/master/examples) directory for \nadditional examples. \n\n## Contribute\n\nAre you interested in contributing? Awesome! Fork, make change, commit and create pull request. I'll do my best to merge \nchanges!\n\n## License\n\n[MIT](/LICENSE)\n"
  },
  {
    "path": "examples/.gitignore",
    "content": "dist\n.cache"
  },
  {
    "path": "examples/multiple-entry-points/package.json",
    "content": "{\n  \"name\": \"multiple-entry-points\",\n  \"version\": \"1.0.0\",\n  \"description\": \"\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"build\": \"parcel build src/*/index.html\"\n  },\n  \"staticFiles\": {\n    \"staticPath\": [\n      {\n        \"staticPath\": \"static\",\n        \"staticOutDir\": \"assets\"\n      }\n    ]\n  },\n  \"devDependencies\": {\n    \"parcel-bundler\": \"1.12.4\",\n    \"parcel-plugin-static-files-copy\": \"file:../..\"\n  },\n  \"dependencies\": {}\n}\n"
  },
  {
    "path": "examples/multiple-entry-points/src/a/index.html",
    "content": "<html>\n<head></head>\n<body></body>\n</html>"
  },
  {
    "path": "examples/multiple-entry-points/src/b/index.html",
    "content": "<html>\n<head></head>\n<body></body>\n</html>"
  },
  {
    "path": "examples/multiple-entry-points/static/dir/test2.txt",
    "content": "test2\n"
  },
  {
    "path": "examples/multiple-entry-points/static/test1.txt",
    "content": "test1\n"
  },
  {
    "path": "examples/multiple-entry-points-with-common-static/package.json",
    "content": "{\n  \"name\": \"multiple-entry-points-with-common-static\",\n  \"version\": \"1.0.0\",\n  \"description\": \"\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"build\": \"parcel build src/*/index.html\"\n  },\n  \"staticFiles\": {\n    \"staticPath\": [\n      {\n        \"staticPath\": \"static\",\n        \"staticOutDir\": \"/assets\"\n      }\n    ]\n  },\n  \"devDependencies\": {\n    \"parcel-bundler\": \"1.12.4\",\n    \"parcel-plugin-static-files-copy\": \"file:../..\"\n  },\n  \"dependencies\": {}\n}\n"
  },
  {
    "path": "examples/multiple-entry-points-with-common-static/src/a/index.html",
    "content": "<html>\n<head></head>\n<body></body>\n</html>"
  },
  {
    "path": "examples/multiple-entry-points-with-common-static/src/b/index.html",
    "content": "<html>\n<head></head>\n<body></body>\n</html>"
  },
  {
    "path": "examples/multiple-entry-points-with-common-static/static/dir/test2.txt",
    "content": "test2\n"
  },
  {
    "path": "examples/multiple-entry-points-with-common-static/static/test1.txt",
    "content": "test1\n"
  },
  {
    "path": "examples/multiple-environments/package.json",
    "content": "{\n  \"name\": \"multiple-environments\",\n  \"version\": \"1.0.0\",\n  \"description\": \"\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"build:dev\": \"NODE_ENV=dev parcel build src/index.html\",\n    \"build:prod\": \"NODE_ENV=prod parcel build src/index.html\"\n  },\n  \"staticFiles\": {\n    \"staticPath\": [\n      {\n        \"staticPath\": \"static-dev\",\n        \"env\": \"dev\"\n      },\n      {\n        \"staticPath\": \"static-dev2\",\n        \"env\": \"dev\"\n      },\n      {\n        \"staticPath\": \"static-prod\",\n        \"env\": \"prod\"\n      }\n    ],\n    \"watcherGlob\": \"**\"\n  },\n  \"devDependencies\": {\n    \"parcel-bundler\": \"1.12.4\",\n    \"parcel-plugin-static-files-copy\": \"file:../..\"\n  },\n  \"dependencies\": {}\n}\n"
  },
  {
    "path": "examples/multiple-environments/src/index.html",
    "content": "<html>\n<head></head>\n<body></body>\n</html>"
  },
  {
    "path": "examples/multiple-environments/static-dev/dev.txt",
    "content": "test1\n"
  },
  {
    "path": "examples/multiple-environments/static-dev2/additional-from-dev2.txt",
    "content": ""
  },
  {
    "path": "examples/multiple-environments/static-prod/prod.txt",
    "content": "test1\n"
  },
  {
    "path": "examples/multiple-nested-config/assets/aaa.txt",
    "content": "asdf"
  },
  {
    "path": "examples/multiple-nested-config/assets/bbb.txt",
    "content": ""
  },
  {
    "path": "examples/multiple-nested-config/assets/ccc.txt",
    "content": "ccc"
  },
  {
    "path": "examples/multiple-nested-config/package.json",
    "content": "{\n  \"name\": \"multiple-nested-config\",\n  \"version\": \"1.0.0\",\n  \"description\": \"\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"build\": \"NODE_ENV=dev parcel build src/index.html\",\n    \"build-prod\": \"NODE_ENV=prod parcel build src/index.html\"\n  },\n  \"staticFiles\": {\n    \"staticPath\": [\n      {\n        \"staticPath\": [\n          \"assets/aaa.txt\",\n          \"assets/bbb.txt\"\n        ],\n        \"env\": \"dev\",\n        \"staticOutDir\": \"vendor1\"\n      },\n      {\n        \"staticPath\": [\n          \"assets/bbb.txt\",\n          \"assets/ccc.txt\"\n        ],\n        \"env\": \"prod\",\n        \"staticOutDir\": \"vendor2\"\n      }\n    ]\n  },\n  \"devDependencies\": {\n    \"parcel-bundler\": \"1.12.4\",\n    \"parcel-plugin-static-files-copy\": \"file:../..\"\n  },\n  \"dependencies\": {}\n}\n"
  },
  {
    "path": "examples/multiple-nested-config/src/index.html",
    "content": "<html>\n<head></head>\n<body></body>\n</html>"
  },
  {
    "path": "examples/multiple-staticpath/package.json",
    "content": "{\n  \"name\": \"multiple-staticpath\",\n  \"version\": \"1.0.0\",\n  \"description\": \"\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"build\": \"parcel build src/index.html\"\n  },\n  \"staticFiles\": {\n    \"staticPath\": [\n      \"static\",\n      \"public\"\n    ],\n    \"watcherGlob\": \"**\"\n  },\n  \"devDependencies\": {\n    \"parcel-bundler\": \"1.12.4\",\n    \"parcel-plugin-static-files-copy\": \"file:../..\"\n  },\n  \"dependencies\": {}\n}\n"
  },
  {
    "path": "examples/multiple-staticpath/public/public.txt",
    "content": "public"
  },
  {
    "path": "examples/multiple-staticpath/src/index.html",
    "content": "<html>\n<head></head>\n<body></body>\n</html>"
  },
  {
    "path": "examples/multiple-staticpath/static/dir/test2.txt",
    "content": "test2\n"
  },
  {
    "path": "examples/multiple-staticpath/static/test1.txt",
    "content": "test1\n"
  },
  {
    "path": "examples/simple/package.json",
    "content": "{\n  \"name\": \"simple\",\n  \"version\": \"1.0.0\",\n  \"description\": \"\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"build\": \"parcel build src/index.html\",\n    \"watch\": \"parcel src/index.html\"\n  },\n  \"staticFiles\": {\n    \"staticPath\": [\n      \"static\",\n      \"static\"\n    ],\n    \"watcherGlob\": \"**\"\n  },\n  \"devDependencies\": {\n    \"parcel-bundler\": \"1.12.4\",\n    \"parcel-plugin-static-files-copy\": \"file:../..\"\n  },\n  \"dependencies\": {}\n}\n"
  },
  {
    "path": "examples/simple/src/index.html",
    "content": "<html>\n<head></head>\n<body></body>\n</html>"
  },
  {
    "path": "examples/simple/static/dir/test2.txt",
    "content": "dir/test2"
  },
  {
    "path": "examples/simple/static/test1.txt",
    "content": "test1\n"
  },
  {
    "path": "examples/simple/static/test2.txt",
    "content": "test2"
  },
  {
    "path": "examples/simple-custom-out-dir/assets/bbb.txt",
    "content": ""
  },
  {
    "path": "examples/simple-custom-out-dir/package.json",
    "content": "{\n  \"name\": \"simple-custom-out-dir\",\n  \"version\": \"1.0.0\",\n  \"description\": \"\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"build\": \"parcel build src/client/index.html -d dist/client\",\n    \"watch\": \"parcel src/client/index.html -d dist/client\"\n  },\n  \"staticFiles\": {\n    \"staticPath\": [\n      {\n        \"staticPath\": \"assets\",\n        \"staticOutDir\": \"assets\"\n      }\n    ],\n    \"watcherGlob\": \"**\"\n  },\n  \"devDependencies\": {\n    \"parcel-bundler\": \"1.12.4\",\n    \"parcel-plugin-static-files-copy\": \"file:../..\"\n  },\n  \"dependencies\": {}\n}\n"
  },
  {
    "path": "examples/simple-custom-out-dir/src/client/index.html",
    "content": "<html>\n<head></head>\n<body></body>\n</html>"
  },
  {
    "path": "examples/single-files/package.json",
    "content": "{\n  \"name\": \"simple\",\n  \"version\": \"1.0.0\",\n  \"description\": \"\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"build\": \"parcel build src/index.html\",\n    \"serve\": \"parcel src/index.html\"\n  },\n  \"staticFiles\": {\n    \"staticPath\": [\n      {\n        \"staticPath\": \"static/test1.txt\",\n        \"staticOutDir\": \"test1\"\n      },\n      {\n        \"staticPath\": \"static/dir/test2.txt\"\n      }\n    ],\n    \"watcherGlob\": \"**\"\n  },\n  \"devDependencies\": {\n    \"parcel-bundler\": \"1.12.4\",\n    \"parcel-plugin-static-files-copy\": \"file:../..\"\n  },\n  \"dependencies\": {}\n}\n"
  },
  {
    "path": "examples/single-files/src/index.html",
    "content": "<html>\n<head></head>\n<body></body>\n</html>"
  },
  {
    "path": "examples/single-files/static/dir/test2.txt",
    "content": "test2\n"
  },
  {
    "path": "examples/single-files/static/test1.txt",
    "content": "test1\n"
  },
  {
    "path": "index.js",
    "content": "'use strict';\nconst fs = require('fs');\nconst minimatch = require('minimatch');\nconst path = require('path');\n\nconst DEFAULT_CONFIG = {\n    'staticPath': ['static'],\n    'watcherGlob': null,\n    'excludeGlob': null,\n    'globOptions': {}\n};\n\nmodule.exports = bundler => {\n    bundler.on('bundled', async (bundle) => {\n\n        // main asset and package dir, depending on version of parcel-bundler\n        let mainAsset =\n            bundler.mainAsset ||                                                // parcel < 1.8\n            bundler.mainBundle.entryAsset ||                                    // parcel >= 1.8 single entry point\n            bundler.mainBundle.childBundles.values().next().value.entryAsset;   // parcel >= 1.8 multiple entry points\n        let pkg;\n        if (typeof mainAsset.getPackage === 'function') {                       // parcel > 1.8\n            pkg = (await mainAsset.getPackage());\n        } else {                                   // parcel <= 1.8\n            pkg = mainAsset.package;\n        }\n\n        // config\n        let config = Object.assign({}, DEFAULT_CONFIG, pkg.staticFiles);\n        if (pkg.staticPath) { // parcel-plugin-static-files-copy<1.2.5\n            config.staticPath = pkg.staticPath;\n        }\n        if (!Array.isArray(config.staticPath)) { // ensure array\n            config.staticPath = [config.staticPath];\n        }\n        if (config.excludeGlob && !Array.isArray(config.excludeGlob)) {\n            config.excludeGlob = [config.excludeGlob];\n        }\n\n        // poor-man's logger\n        const logLevel = parseInt(bundler.options.logLevel);\n        const pmLog = (level, ...msgs) => {\n            if (logLevel >= level) {\n                console.log(...msgs);\n            }\n        };\n\n        // static paths are usually just a string can be specified as\n        // an object to make them conditional on the output directory\n        // by specifying them in the form\n        // {\"outDirPattern\":\"dist1\", \"staticPath\":\"static1\"},\n        // {\"outDirPattern\":\"dist2\", \"staticPath\":\"static2\"}\n        config.staticPath = config.staticPath.map(path => {\n            if (typeof path === 'object') {\n                if (!path.staticPath) {\n                    console.error(`Error: parcel-plugin-static-files-copy: When staticPath is an object, expecting it to have at least the 'staticPath' key, but found: ${path}`);\n                    return null;\n                }\n\n                if (path.outDirPattern) {\n                    if (minimatch(bundler.options.outDir, path.outDirPattern, config.globOptions)) {\n                        pmLog(4, `outDir matches '${path.outDirPattern}' so copying static files from '${path.staticPath}'`);\n                    } else {\n                        pmLog(4, `outDir does not match '${path.outDirPattern}' so not copying static files from '${path.staticPath}'`);\n                        return null;\n                    }\n                }\n\n                return path;\n            } else {\n                return {staticPath: path};\n            }\n        }).filter(path => path != null);\n\n        // recursive copy function\n        let numWatches = 0;\n\n        /**\n         * Recurse into directory and execute callback function for each file and folder.\n         *\n         * Based on https://github.com/douzi8/file-system/blob/master/file-system.js#L254\n         *\n         * @param dirpath directory to start from\n         * @param callback function to be run on every file/directory\n         */\n        const recurseSync = (dirpath, callback) => {\n            const rootpath = dirpath;\n\n            function recurse(dirpath) {\n                fs.readdirSync(dirpath).forEach(function (filename) {\n                    const filepath = path.join(dirpath, filename);\n                    const stats = fs.statSync(filepath);\n                    const relative = path.relative(rootpath, filepath);\n\n                    if (stats.isDirectory()) {\n                        callback(filepath, relative);\n                        recurse(filepath);\n                    } else {\n                        callback(filepath, relative, filename);\n                    }\n\n                });\n            }\n\n            recurse(dirpath);\n        };\n\n        function copySingleFile(bundleDir, dest, filepath) {\n            if (fs.existsSync(dest)) {\n                const destStat = fs.statSync(dest);\n                const srcStat = fs.statSync(filepath);\n                if (destStat.mtime < srcStat.mtime) { // File was modified - let's copy it and inform about overwriting.\n                    pmLog(3, `Static file '${filepath}' already exists in '${bundleDir}'. Overwriting.`);\n                    fs.copyFileSync(filepath, dest);\n                }\n            } else {\n                fs.copyFileSync(filepath, dest);\n            }\n            // watch for changes?\n            if (config.watcherGlob && bundler.watcher && minimatch(filepath, config.watcherGlob, config.globOptions)) {\n                numWatches++;\n                bundler.watch(filepath, mainAsset);\n            }\n        }\n\n        const shouldBeExcluded = (file, staticPath, excludeGlob) => {\n            return !!excludeGlob.find(excludeGlob =>\n                minimatch(file, path.join(staticPath, excludeGlob), config.globOptions)\n            );\n        };\n\n        const copyFile = (filepath, bundleDir, excludeGlob) => {\n            if (shouldBeExcluded(filepath, path.dirname(filepath), excludeGlob)) {\n                return;\n            }\n            const dest = path.join(bundleDir, path.basename(filepath));\n            copySingleFile(bundleDir, dest, filepath);\n        };\n\n        const copyDir = (staticDir, bundleDir, excludeGlob) => {\n            const copy = (filepath, relative, filename) => {\n                if (shouldBeExcluded(filepath, staticDir, excludeGlob)) {\n                    return;\n                }\n\n                const dest = filepath.replace(staticDir, bundleDir);\n                if (!filename) {\n                    if (!fs.existsSync(dest)) {\n                        fs.mkdirSync(dest, {recursive: true});\n                    }\n                } else {\n                    copySingleFile(bundleDir, dest, filepath);\n                }\n            };\n            recurseSync(staticDir, copy);\n        };\n\n        const outDir = bundler.options.outDir;\n        const currentEnv = process.env.NODE_ENV;\n\n        function processStaticFiles(singleBundle) {\n            for (let dir of config.staticPath) {\n                if (dir.env && dir.env !== currentEnv) {\n                    continue;\n                }\n\n                const copyTo = dir.staticOutDir && dir.staticOutDir.startsWith('/')\n                    ? path.join(outDir, dir.staticOutDir)\n                    : path.join(path.dirname(singleBundle.name), dir.staticOutDir ? dir.staticOutDir : '');\n                // merge global exclude glob with static path exclude glob\n                const excludeGlob = (config.excludeGlob || []).concat((dir.excludeGlob || []));\n\n                if (!fs.existsSync(copyTo)) {\n                    fs.mkdirSync(copyTo, {recursive: true});\n                }\n\n                var paths = dir.staticPath;\n                if (!Array.isArray(paths)) {\n                    paths = [paths];\n                }\n                for (let singlePath of paths) {\n                    let staticPath = path.join(pkg.pkgdir, singlePath);\n                    if (!fs.existsSync(staticPath)) {\n                        pmLog(2, `Static path (file or directory) '${staticPath}' does not exist. Skipping.`);\n                        continue;\n                    }\n                    if (fs.statSync(staticPath).isDirectory()) {\n                        copyDir(staticPath, copyTo, excludeGlob);\n                    } else {\n                        copyFile(staticPath, copyTo, excludeGlob);\n                    }\n                }\n            }\n        }\n\n        if (!bundle.name) { // multiple entry points\n            for (let singleBundle of bundler.mainBundle.childBundles.values()) {\n                processStaticFiles(singleBundle);\n            }\n        } else {\n            processStaticFiles(bundle);\n        }\n\n        if (config.watcherGlob && bundler.watcher) {\n            pmLog(3, `Watching for changes in ${numWatches} static files.`);\n        }\n\n    });\n};\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"author\": {\n    \"name\": \"Kamil Banach\",\n    \"email\": \"kontakt@elwin013.com\"\n  },\n  \"bugs\": {\n    \"url\": \"https://github.com/elwin013/parcel-plugin-static-files-copy/issues\"\n  },\n  \"dependencies\": {\n    \"minimatch\": \"3.0.4\",\n    \"path\": \"0.12.7\"\n  },\n  \"deprecated\": false,\n  \"description\": \"ParcelJS plugin to copy static files from static dir to bundle directory.\",\n  \"devDependencies\": {\n    \"eslint\": \"5.12.0\"\n  },\n  \"homepage\": \"https://github.com/elwin013/parcel-plugin-static-files-copy#readme\",\n  \"keywords\": [\n    \"parcel\"\n  ],\n  \"license\": \"MIT\",\n  \"main\": \"index.js\",\n  \"name\": \"parcel-plugin-static-files-copy\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+ssh://git@github.com/elwin013/parcel-plugin-static-files-copy.git\"\n  },\n  \"scripts\": {\n    \"test\": \"eslint index.js\"\n  },\n  \"version\": \"2.6.0\"\n}\n"
  }
]