I'm in the midst of migrating a large NativeScript 6.8 JavaScript project to NativeScript 8.1. My current obstacle is adding a service to the new webpack.config.js. Here's the lines from the old file:
appComponents.push(...[
"tns-core-modules/ui/frame",
"tns-core-modules/ui/frame/activity",
resolve(__dirname, "./app/foreground-service.android.js"), // <-- this is the addition
]);
I've read through the referenced documentation several times but am not understanding how to specify this in the new webpack config. I'd welcome any insights.
For context, see this Nativescript-geolocation issue.
For the new webpack in ns8 to build a your custom service, write your webpack.config.js like this:
const webpack = require('@nativescript/webpack')
module.exports = env => {
env.appComponents = (env.appComponents || []).concat(['./src/app/foreground-service.android'])
webpack.init(env)
return webpack.resolveConfig()
}
More on webpack config for ns8 see https://docs.nativescript.org/webpack.html#webpack-chainwebpack-chainfn-options and https://docs.nativescript.org/advanced-concepts.html#extending-android-activity