All Projects → webpack-contrib → Node Loader

webpack-contrib / Node Loader

Licence: mit
node loader for native modules

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Node Loader

Node Addon Loader
A loader for node native addons
Stars: ✭ 17 (-77.92%)
Mutual labels:  webpack-loader
Svgr
Transform SVGs into React components 🦁
Stars: ✭ 8,263 (+10631.17%)
Mutual labels:  webpack-loader
Sketch Loader
Webpack loader for Sketch (+43) files
Stars: ✭ 69 (-10.39%)
Mutual labels:  webpack-loader
Angular2 Load Children Loader
A webpack loader for ng2 lazy loading
Stars: ✭ 23 (-70.13%)
Mutual labels:  webpack-loader
Thread Loader
Runs the following loaders in a worker pool
Stars: ✭ 945 (+1127.27%)
Mutual labels:  webpack-loader
Ng Router Loader
Webpack loader for NgModule lazy loading using the angular router
Stars: ✭ 47 (-38.96%)
Mutual labels:  webpack-loader
Node Config Loader
Scan directories and loads config json and yaml files
Stars: ✭ 5 (-93.51%)
Mutual labels:  webpack-loader
Graphql Persisted Document Loader
Webpack loader that adds a documentId to a compiled graphql document, which can be used when persisting/retrieving documents
Stars: ✭ 74 (-3.9%)
Mutual labels:  webpack-loader
Mpx Webpack Plugin
原生小程序开发定制 webpack 插件套装
Stars: ✭ 34 (-55.84%)
Mutual labels:  webpack-loader
Isomorphine
Require server-side modules from the browser, remotely.
Stars: ✭ 66 (-14.29%)
Mutual labels:  webpack-loader
Stylefmt Loader
Webpack-loader. Fixes stylelint issues automatically while bundling with Webpack.
Stars: ✭ 24 (-68.83%)
Mutual labels:  webpack-loader
Flow Bin Loader
webpack loader for Flow
Stars: ✭ 11 (-85.71%)
Mutual labels:  webpack-loader
Html Loader
HTML Loader
Stars: ✭ 1,067 (+1285.71%)
Mutual labels:  webpack-loader
Nunjucks Isomorphic Loader
Nunjucks loader for webpack, supporting both javascript templating and generating static HTML files through the HtmlWebpackPlugin.
Stars: ✭ 17 (-77.92%)
Mutual labels:  webpack-loader
Jshint Loader
[DEPRECATED] jshint loader for webpack, please migrate on `eslint`
Stars: ✭ 69 (-10.39%)
Mutual labels:  webpack-loader
Inline Style Loader
inline style loader for webpack
Stars: ✭ 16 (-79.22%)
Mutual labels:  webpack-loader
Bootstrap Loader
Load Bootstrap styles and scripts in your Webpack bundle
Stars: ✭ 1,038 (+1248.05%)
Mutual labels:  webpack-loader
Svg Fill Loader
DEPRECATED, use https://github.com/kisenka/svg-mixer/tree/master/packages/svg-transform-loader instead
Stars: ✭ 74 (-3.9%)
Mutual labels:  webpack-loader
Svg Sprite Webpack Plugin
Webpack plugin for loading/extracting SVGs into a sprite file
Stars: ✭ 73 (-5.19%)
Mutual labels:  webpack-loader
Laravel Localization Loader
Laravel Localization loader for webpack. Convert Laravel Translation strings to JavaScript Objects.
Stars: ✭ 58 (-24.68%)
Mutual labels:  webpack-loader

npm node deps tests coverage chat size

node-loader

A Node.js add-ons loader.

Allows to connect native node modules with .node extension.

node-loader only works on the node/electron-main/electron-main targets.

Getting Started

To begin, you'll need to install node-loader:

$ npm install node-loader --save-dev

Setup the target option to node/electron-main/electron-main value and do not mock the __dirname global variable.

webpack.config.js

module.exports = {
  target: 'node',
  node: {
    __dirname: false,
  },
  module: {
    rules: [
      {
        test: /\.node$/,
        loader: 'node-loader',
      },
    ],
  },
};

Inline

index.js

import node from 'node-loader!./file.node';

And run webpack via your preferred method.

Configuration

index.js

import node from 'file.node';

Then add the loader to your webpack config. For example:

webpack.config.js

module.exports = {
  target: 'node',
  node: {
    __dirname: false,
  },
  module: {
    rules: [
      {
        test: /\.node$/,
        loader: 'node-loader',
      },
    ],
  },
};

And run webpack via your preferred method.

Options

Name Type Default Description
flags {Number} undefined Enables/Disables url/image-set functions handling
name {String|Function} '[contenthash].[ext]' Specifies a custom filename template for the target file(s).

flags

Type: Number Default: undefined

The flags argument is an integer that allows to specify dlopen behavior. See the [process.dlopen][https://nodejs.org/api/process.html#process_process_dlopen_module_filename_flags] documentation for details.

index.js

import node from 'file.node';

webpack.config.js

const os = require('os');

module.exports = {
  target: 'node',
  node: {
    __dirname: false,
  },
  module: {
    rules: [
      {
        test: /\.node$/,
        loader: 'node-loader',
        options: {
          flags: os.constants.dlopen.RTLD_NOW,
        },
      },
    ],
  },
};

name

Type: String|Function Default: '[contenthash].[ext]'

Specifies a custom filename template for the target file(s).

String

webpack.config.js

module.exports = {
  target: 'node',
  node: {
    __dirname: false,
  },
  module: {
    rules: [
      {
        test: /\.node$/,
        loader: 'node-loader',
        options: {
          name: '[path][name].[ext]',
        },
      },
    ],
  },
};

Function

webpack.config.js

module.exports = {
  target: 'node',
  node: {
    __dirname: false,
  },
  module: {
    rules: [
      {
        test: /\.node$/,
        loader: 'node-loader',
        options: {
          name(resourcePath, resourceQuery) {
            // `resourcePath` - `/absolute/path/to/file.js`
            // `resourceQuery` - `?foo=bar`

            if (process.env.NODE_ENV === 'development') {
              return '[path][name].[ext]';
            }

            return '[contenthash].[ext]';
          },
        },
      },
    ],
  },
};

Contributing

Please take a moment to read our contributing guidelines if you haven't yet done so.

CONTRIBUTING

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].