Webpack Import Replace

by Nathan Walker

Replace imports with .ios or .android suffix for target mobile platforms.

ImportReplacePlugin

NativeScript webpack plugin to rewrite various imports with the .ios or .android platform suffix to allow various Angular Components, Directives, or Pipes to properly AoT compile when building a NativeScript for Angular app.

Install

npm install nativescript-webpack-import-replace --save-dev

Usage

In your app's webpack.config.js, add the following:

function getPlugins(platform, env) {
    let plugins = [
      ...
      new ImportReplacePlugin({
          debug: true, // optional - outputs results
          platform: platform,
          files: [
              'slider.directive'
          ]
      }),
      ...

The files collection can be a list of import filenames you'd like replaced with the target platform suffix. The plugin will find the import and add the proper platform ending to the import to allow a pro