Socket
Socket
Sign inDemoInstall

nativescript-hook-env-files

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

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)


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Created
Weekly downloads
 

Readme

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

Last updated on 28 Jun 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc