JSPM

@nativescript/webpack

5.0.31
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6070
  • Score
    100M100P100Q122377F
  • License Apache-2.0

Package Exports

  • @nativescript/webpack
  • @nativescript/webpack/dist/bin/index.js
  • @nativescript/webpack/dist/cli/parseEnvFlags
  • @nativescript/webpack/dist/cli/parseEnvFlags.js
  • @nativescript/webpack/dist/helpers/platform
  • @nativescript/webpack/dist/helpers/platform.js
  • @nativescript/webpack/dist/index.js
  • @nativescript/webpack/dist/plugins/PlatformSuffixPlugin
  • @nativescript/webpack/dist/plugins/PlatformSuffixPlugin.js
  • @nativescript/webpack/dist/transformers/NativeClass
  • @nativescript/webpack/dist/transformers/NativeClass/index.js
  • @nativescript/webpack/package.json

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@nativescript/webpack) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

NativeScript

@nativescript/webpack

Webpack configuration for NativeScript apps.

npm version license downloads

Documentation ยท Environment Setup ยท Contribute ยท Community


All NativeScript applications are bundled using webpack. This package provides the required configuration to build NativeScript apps with flexibility to customize as needed.

๐Ÿ“ฆ Installation

npm install @nativescript/webpack --save-dev

๐Ÿš€ Quick Start

All new projects come with a base webpack.config.js that's pre-configured:

const webpack = require('@nativescript/webpack')

module.exports = (env) => {
  webpack.init(env)

  // Learn how to customize:
  // https://docs.nativescript.org/webpack

  return webpack.resolveConfig()
}

โœจ Features

  • Auto-discovery: Automatically detects your project type (TypeScript, Angular, Vue, React, Svelte)
  • Hot Module Replacement: HMR enabled by default for faster development
  • DotEnv Support: Built-in support for .env files to manage environment variables
  • Bundle Analysis: Generate bundle reports with --env.report
  • Production Optimization: Minification with Terser in production mode

๐Ÿ”ง Global Variables

Useful globally available variables in your app:

Variable Description
__DEV__ true when building in development mode
global.isAndroid / __ANDROID__ true when platform is Android
global.isIOS / __IOS__ true when platform is iOS
global.isVisionOS / __VISIONOS__ true when platform is visionOS
global.__APPLE__ true when platform is iOS or visionOS

๐Ÿ“š API

Core Methods

Method Description
webpack.init(env) Initialize the internal env object (required)
webpack.chainWebpack(chainFn) Add chain functions to modify config
webpack.mergeWebpack(obj) Merge objects into the final config
webpack.resolveConfig() Resolve the final webpack configuration

๐ŸŽ›๏ธ CLI Flags

Flag Description
--no-hmr Disable Hot Module Replacement
--env.production Enable production mode with minification
--env.report Generate bundle analysis report
--env.verbose Print verbose logs and internal config
--env.e2e Enable E2E mode (enables testID property)

๐Ÿ“– Documentation

For complete documentation including configuration examples, visit the webpack configuration guide.

๐Ÿ“„ License

MIT licensed.