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

nativescript-hook-env-files

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nativescript-hook-env-files

A nativescript hook to replace file according to NODE_ENV value. Inspired by [nativescript-hook-debug-production](https://github.com/markosko/nativescript-hook-debug-production)

  • 0.1.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

nativescript-hook-env-files

A nativescript hook to replace file according to NODE_ENV value. Inspired by nativescript-hook-debug-production

Example

Project directory structure

app
├ env.development.json # {"production": false}
├ env.production.json  # {"production": true}
├ main.ts
├ ...

In your app code

const env = require('./env.json');

console.log(env.production); // 'true' if tns build or run with NODE_ENV=production, otherwise 'false'.

Webpack+Angular support

Add hostReplacementPaths option to NativescriptAngularCompilerPlugin in your webpack.config.js.

// utility method for getting replacement targets.
const { getReplacementPaths } = require('nativescript-hook-env-files/webpack');
new nsWebpack.NativeScriptAngularCompilerPlugin({
    entryModule: resolve(appPath, "app.module#AppModule"),
    tsConfigPath: join(__dirname, "tsconfig.esm.json"),
    skipCodeGeneration: !aot,
    platformOptions: {
        platform,
        platforms,
    },
    hostReplacementPaths: getReplacementPaths(appFullPath, process.env.NODE_ENV || 'development'), // add this line
}),

FAQs

Package last updated on 28 Jun 2018

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