If webpack has `webpack: //` urls in production builds with sitemaps?

I know that you should not have them in production anyway, and in the past I noticed that webpack:// was seen in my dev lines using webpack-dev-server and did not know what was expected in prod builds.

If webpack has webpack:// , if you have an assembly with sitemaps?

For example, if I look at my development, build a site map with something like build/bundle.js.map , I see webpack:// to map to my file location using webpack-dev-server for a faster reboot (and I'm sure more) in dev mode and just wondering what is expected for production?

+5
source share
2 answers

The original question jumps a bit, so I will try to answer the question, as I see it:

Will the source maps for the "production" builds using webpack still have the webpack:// -style paths for the source paths?

First of all, there really is no such thing as a production assembly when it comes to the inside of webpack. In fact, there are 0 references to NODE_ENV in the actual webpack source code.

This is important to note because it opens the way to understanding that the web package is not aware of the environment in which it is built. Thus, the output of the webpack package does not change unless you change it, i.e. By changing the use of webpack configuration.

Moving to the source maps, all devtools (types of source maps) use roughly the same (custom) devtool file template . All file names used by devtools (source maps) follow this pattern, which starts with webpack:// by default. Thus, all the paths generated for the source maps start with webpack:// , taking into account the default value.

So, to answer the above question: yes , the source maps of the β€œproduction” builds will have paths using the webpack:// protocol, if output.devtoolModuleFilenameTemplate .

+1
source

You can change this in the package.json file

  "scripts":{ "start" : "webapck" } 

after you get bundle.js or any other files. After adding the .js files to the html file. And then run your html page in any other environment like nodeJs ...

0
source

Source: https://habr.com/ru/post/1274049/


All Articles