How to open Firefox Developer Edition with Webpack serve and DevServer --open option?

1k Views Asked by At

How to open Firefox Developer Edition with webpack serve using devServer.open config option?

I've tried to use these configuration values on Windows: 'Mozilla', 'mozilla', 'Firefox', 'firefox', 'Firefox Developer Edition'

devServer: {
  open: 'mozilla',
},

EDIT: Thanks for the answers. Am looking to see which one casts more votes, to see what works for the people. Solution may vary i.e. per OS version.

3

There are 3 best solutions below

0
On

I had the same issue, found a workaround.

You need to set Firefox Developer Edition as a default browser in order for it to work.

https://www.npmjs.com/package/open#target

target

Type: string

The thing you want to open. Can be a URL, file, or executable.

Opens in the default app for the file type. For example, URLs opens in your default browser.

Then add target property to your webpack.config.js like this

devServer: {
    contentBase: './dist',
    open: {
        target: 'index.html'
    }
}

I'm using Ubuntu so I'm not sure if it will work on Windows.

0
On

For macOS user

In order to open Firefox Developer Edition with webpack serve using devServer.open option, you can write the name of the app like this:

devServer: {
    contentBase: path.join(__dirname, "dist"),
    compress: true,
    open: "Firefox Developer Edition",
    port: 9001,
    historyApiFallback: true,
    stats: {
      colors: true,
    },
  }

As for the other browsers, you need to write the exact name you see in your Applications folder. Like when you open your browser with your terminal app.


  1. This question gave me the idea see here
  2. Tested on macOS Big Sur
  3. Webpack v5.36.2
  4. Webpack-CLI v4.7.0
  5. webpack DevServer v3.11.2
0
On

You can specify the full path to the browser you want to use. Note that this will only work on one machine, so do not use it in shared projects, or use an environment variable. This config worked for me:

devServer: {
    open: 'C:\\Program Files\\Firefox Developer Edition\\firefox.exe'
},