Webpack

This section is only applicable to @nativescript/webpack version 5.0.0 and above. If you are using an older version, consider upgrading. This is compatible with a Webpack version 5.x.

All NativeScript applications are bundled using webpack. To manage the required configuration, we maintain the @nativescript/webpack package.

All new projects come with the base webpack.config.js that’s pre-configured to build a NativeScript app:

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

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

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

  return webpack.resolveConfig()
}

The above config configures most things required to bundle a NativeScript application. Internally, it’s using a webpack-chain to generate the final config that is passed to webpack.

In some cases, you may wish to extend the configuration, which is possible using the API for applications, and the Plugin API for plugins. This page contains many examples of common things you might want to change in the Examples of Configurations Section — for anything else not mentioned here, refer to the webpack-chain documentation.