15

I'm using webpack 3.10 and I've got different webpack configs for dev/prod. Now in my prod config "devtool = "(none)"" is set, while in my dev config it is "eval-source-map".

Sadly using the prod config, my bundle is non functional. While using the dev config everything is working fine. I tried around a bit and every setting that is flagged as "production: yes" on in the webpack docs: https://webpack.js.org/configuration/devtool/ breaks my code.

Can anyone explain the exact difference between the settings. Is there anything else that changes (minifying/uglyfying whatever)?

Kind regards.

Schadenn
  • 854
  • 1
  • 9
  • 20
  • 2
    This doesn't appear to be valid syntax: `"devtool = "(none)""` Also, I think you're maybe taking the documentation too literally, `(none)` should just be `null` or an empty string `''`. It would be helpful to see more of your actual config code. – joknawe Jul 05 '18 at 18:43
  • https://codesandbox.io/s/k0lmjlqmj7 I created the 2 webpack files as im using them in this sandbox. There's really not much difference. Also as I said any other production: yes value for the devtool parameter (like "source-map" as in the sandbox) breaks it. – Schadenn Jul 06 '18 at 06:23
  • Okay. Parts of my (/our) code weren't minification save at all. Checking react components' types as string. So the minification just broke it. It's fine now. Webpack is all good :) – Schadenn Jul 09 '18 at 08:58
  • iI think t should be devtool = false in webpack 5 and before that it should be devtool="none" – Ishan Fernando Apr 02 '22 at 14:19

2 Answers2

25

In webpack 5.2.0, you can declare the config as devtool: false in production for the (none) functionality.

NOTE: If you have mode: "development" and you do not mention devtool in your webpack config, the devtool defaults to eval.

Noopur Phalak
  • 878
  • 1
  • 13
  • 22
0

That's not how you use it. To make it work, you shouldn't specify a devtool key. Not a null value or (none), you simply shouldn't have the devtool key on your configuration.

{
  ...
  plugins: [],
  optimization: {}
  ...
}

Without any devtool in between.

Gabriel Bueno
  • 480
  • 1
  • 4
  • 17
  • 2
    Not true in case of `mode: development`. In development mode, the `devtool` defaults to `eval`. – Noopur Phalak Oct 27 '20 at 13:48
  • 3
    Well, there's a boolean option. Simply can set it to `false` which will be very useful in programmatical usage of webpack. – m4heshd Jan 19 '21 at 14:13