Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-file-path-loader

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-file-path-loader

A webpack loader that get the absolute path of file imported at runtime.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

node-file-path-loader

Actions Status

A webpack loader that get the absolute path of file imported at runtime.

Why?

This is useful when you are using webpack to build your Node.js/Electron project and just want the absolute path of the file instead of contents. For example, use this loader to get your absolute resources path in Electron at runtime.

import iconPath from "@/resources/image/icon.ico";

const win = new BrowserWindow({ icon: iconPath });

Another scenario is that if you're using typescript to write your worker file, it would be much easier to load your worker file by using ts-loader with this loader.

import compiledWorkerPath from "node-file-path-loader!ts-loader!./worker.ts";

const worker = new Worker(workerPath);

Notification

  1. This loader is only works in Node.js environments, like Node.js/Electron.

Installation

npm install node-file-path-loader

Necessary webpack configurations

You need to set webpack target to node and disable mocking of __dirname.

// webpack.config.js
module.exports = {
  target: "node",
  node: {
    __dirname: false,
  },
};

Options

outputPath

Type: String Default: undefined

Specify a filesystem path where the target file(s) will be placed.

Keywords

FAQs

Package last updated on 13 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc