How to disable bundling in Webpack for development

2019-06-16 03:39发布

问题:

In my web app I was using RequireJS to asynchronously load my javascript files on demand. This worked well for dev - when debugging my app I could see which script is dependent on which and order in which they were loaded. This simplified debugging.

Later I switched to Webpack as it is much easier in configuration and easier to maintain. So Webpack now generates for me nice bundles containing my javascript code. This works perfectly well but what I'd like to have is an imitation of my previous RequireJS configuration for dev time.

When I am developing my app I want Webpack to generate some simple entry point (just like in RequireJS) which would load my javascript files one by one through their "require" references. At the same time I still want that Webpack performed normal bundling when I deploy my app to a server.

Is this possible to achieve?

回答1:

Enable Devtools in webpack.config.js to control and generate source maps (Source Maps enhance debugging process).

webpack.config.js

  devtool: "#inline-source-map",

Chrome Debugger View



回答2:

Nope, that's not possible. But have you tried the devtool-option? It maps back your original files in your devtools so you should see no difference whether the modules were in different files or just all in one.