{"name":"node-loader","version":"0.6.0","author":{"name":"Tobias Koppers @sokra"},"description":"node loader module for enhanced-require","licenses":[{"type":"MIT","url":"http://www.opensource.org/licenses/mit-license.php"}],"gitHead":"c701e37c1a4105df6984bb5233a021aff3a07916","_id":"node-loader@0.6.0","scripts":{},"_shasum":"c797ef51095ed5859902b157f6384f6361e05ae8","_from":".","_npmVersion":"3.3.3","_nodeVersion":"6.3.1","_npmUser":{"name":"sokra","email":"tobias.koppers@googlemail.com"},"dist":{"shasum":"c797ef51095ed5859902b157f6384f6361e05ae8","tarball":"http://registry-npm.ywwl.com/node-loader/download/node-loader-0.6.0.tgz","integrity":"sha512-WlUacqHqHWb383Mec656pJmAtg7EXBcijg1sovgy0tI4xevAzv8RqcRARTMlzm0HLXzy1Pdo/DMU19/fxoMnmA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAWxdr7qjgcBggPBpJMnR7bRExximI5iD9SQijuLXFYIAiAtBZpKWAOMKd4SGn/ZAu0weDPhIfLcFuacRz9cE7IHMg=="}],"size":621,"noattachment":false,"key":"/node-loader/-/node-loader-0.6.0.tgz"},"maintainers":[{"name":"sokra","email":"tobias.koppers@googlemail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/node-loader-0.6.0.tgz_1473885695422_0.8098734004888684"},"directories":{},"readme":"<div align=\"center\">\n  <a href=\"https://github.com/webpack/webpack\">\n    <img width=\"200\" height=\"200\" src=\"https://webpack.js.org/assets/icon-square-big.svg\">\n  </a>\n</div>\n\n[![npm][npm]][npm-url]\n[![node][node]][node-url]\n[![deps][deps]][deps-url]\n[![tests][tests]][tests-url]\n[![coverage][cover]][cover-url]\n[![chat][chat]][chat-url]\n[![size][size]][size-url]\n\n# node-loader\n\nA [Node.js add-ons](https://nodejs.org/dist/latest/docs/api/addons.html) loader.\n\nAllows to connect native node modules with `.node` extension.\n\n> ⚠ `node-loader` only works on the `node`/`electron-main`/`electron-main` targets.\n\n## Getting Started\n\nTo begin, you'll need to install `node-loader`:\n\n```console\n$ npm install node-loader --save-dev\n```\n\nSetup the `target` option to `node`/`electron-main`/`electron-main` value and do not mock the `__dirname` global variable.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  target: \"node\",\n  node: {\n    __dirname: false,\n  },\n  module: {\n    rules: [\n      {\n        test: /\\.node$/,\n        loader: \"node-loader\",\n      },\n    ],\n  },\n};\n```\n\n### Inline\n\n**index.js**\n\n```js\nimport node from \"node-loader!./file.node\";\n```\n\nAnd run `webpack` via your preferred method.\n\n### Configuration\n\n**index.js**\n\n```js\nimport node from \"file.node\";\n```\n\nThen add the loader to your `webpack` config. For example:\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  target: \"node\",\n  node: {\n    __dirname: false,\n  },\n  module: {\n    rules: [\n      {\n        test: /\\.node$/,\n        loader: \"node-loader\",\n      },\n    ],\n  },\n};\n```\n\nAnd run `webpack` via your preferred method.\n\n## Options\n\n|         Name          |         Type         |         Default         | Description                                                  |\n| :-------------------: | :------------------: | :---------------------: | :----------------------------------------------------------- |\n| **[`flags`](#flags)** |      `{Number}`      |       `undefined`       | Enables/Disables `url`/`image-set` functions handling        |\n|  **[`name`](#name)**  | `{String\\|Function}` | `'[contenthash].[ext]'` | Specifies a custom filename template for the target file(s). |\n\n### `flags`\n\nType: `Number`\nDefault: `undefined`\n\nThe `flags` argument is an integer that allows to specify dlopen behavior.\nSee the [`process.dlopen`][https://nodejs.org/api/process.html#process_process_dlopen_module_filename_flags] documentation for details.\n\n**index.js**\n\n```js\nimport node from \"file.node\";\n```\n\n**webpack.config.js**\n\n```js\nconst os = require(\"os\");\n\nmodule.exports = {\n  target: \"node\",\n  node: {\n    __dirname: false,\n  },\n  module: {\n    rules: [\n      {\n        test: /\\.node$/,\n        loader: \"node-loader\",\n        options: {\n          flags: os.constants.dlopen.RTLD_NOW,\n        },\n      },\n    ],\n  },\n};\n```\n\n### `name`\n\nType: `String|Function`\nDefault: `'[contenthash].[ext]'`\n\nSpecifies a custom filename template for the target file(s).\n\n#### `String`\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  target: \"node\",\n  node: {\n    __dirname: false,\n  },\n  module: {\n    rules: [\n      {\n        test: /\\.node$/,\n        loader: \"node-loader\",\n        options: {\n          name: \"[path][name].[ext]\",\n        },\n      },\n    ],\n  },\n};\n```\n\n#### `Function`\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  target: \"node\",\n  node: {\n    __dirname: false,\n  },\n  module: {\n    rules: [\n      {\n        test: /\\.node$/,\n        loader: \"node-loader\",\n        options: {\n          name(resourcePath, resourceQuery) {\n            // `resourcePath` - `/absolute/path/to/file.js`\n            // `resourceQuery` - `?foo=bar`\n\n            if (process.env.NODE_ENV === \"development\") {\n              return \"[path][name].[ext]\";\n            }\n\n            return \"[contenthash].[ext]\";\n          },\n        },\n      },\n    ],\n  },\n};\n```\n\n## Contributing\n\nPlease take a moment to read our contributing guidelines if you haven't yet done so.\n\n[CONTRIBUTING](./.github/CONTRIBUTING.md)\n\n## License\n\n[MIT](./LICENSE)\n\n[npm]: https://img.shields.io/npm/v/node-loader.svg\n[npm-url]: https://npmjs.com/package/node-loader\n[node]: https://img.shields.io/node/v/node-loader.svg\n[node-url]: https://nodejs.org\n[deps]: https://david-dm.org/webpack-contrib/node-loader.svg\n[deps-url]: https://david-dm.org/webpack-contrib/node-loader\n[tests]: https://github.com/webpack-contrib/node-loader/workflows/node-loader/badge.svg\n[tests-url]: https://github.com/webpack-contrib/node-loader/actions\n[cover]: https://codecov.io/gh/webpack-contrib/node-loader/branch/master/graph/badge.svg\n[cover-url]: https://codecov.io/gh/webpack-contrib/node-loader\n[chat]: https://badges.gitter.im/webpack/webpack.svg\n[chat-url]: https://gitter.im/webpack/webpack\n[size]: https://packagephobia.now.sh/badge?p=node-loader\n[size-url]: https://packagephobia.now.sh/result?p=node-loader\n","publish_time":1473885697255,"_cnpm_publish_time":1473885697255,"dist-tags":{"latest":"2.1.0"}}