https://kotlinlang.org logo
#javascript
Title
# javascript
t

Tobias Wohlfarth

11/29/2023, 8:24 PM
I recently startet with some small Kotlin/JS for Frontend things. When i run the gradle task jsRun it opens the website in my main browser(Firefox), but i want do my development in Firefox Nightly which is installed too. How do i specify which browser the gradle task should open?
h

Hildebrandt Tobias

11/29/2023, 11:17 PM
From what I gathered gradle always opens the default browser. Sadly I was unable to find how to configure the task to use another one. Maybe this helps you to also open the app in the nightly browser. https://stackoverflow.com/questions/14847296/gradle-task-to-open-a-url-in-the-default-browser
t

Tobias Wohlfarth

11/29/2023, 11:39 PM
Meanwhile i found a solution/workaround: Thats somehow connected with webpack: Configure webpack with https://kotlinlang.org/docs/js-project-setup.html#webpack-task https://webpack.js.org/configuration/dev-server/#devserveropen My config file:
Copy code
config.devServer = {
  "open": {
    "app": {
      "name": 'firefox-nightly',
    }
  },
  "static": [
    "kotlin",
    "../../../processedResources/js/main"
  ],
  "client": {
    "overlay": {
      "errors": true,
      "warnings": false
    }
  }
};
I assume this overwrites the complete config object for devServer, but I didn't know the syntax for only adding custom
open
key
h

Hildebrandt Tobias

11/29/2023, 11:45 PM
Good find!
As to not overwrite the config, which can cause headaches, you might want to use this format:
Copy code
;(function(config) {
    config.mode = 'development'
    if(!config.hasOwnProperty('devServer')) {
        config.devServer = { }
    }
    config.devServer.host = 'developer.local'
    config.devServer.port = 8080
    config.devServer.historyApiFallback = true
    config.devServer.devMiddleware = {

        publicPath: '/',
        mimeTypes: { "text/html": ["phtml"] },
    }
    // config.devServer.historyApiFallback = true
})(config);
Just as a reference. This way, changes from other sources aren't overwritten. (I just copied it from my Playground project)
👍 1
4 Views