如何在Webpack中禁用捆绑以进行开发? [英] How to disable bundling in Webpack for development?

查看:154
本文介绍了如何在Webpack中禁用捆绑以进行开发?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网络应用程序中,我使用RequireJS按需异步加载我的javascript文件。这对dev很有用 - 在调试我的应用程序时,我可以看到哪个脚本依赖于它们的加载顺序。这简化了调试。



后来我改用Webpack,因为它更容易配置,更容易维护。所以Webpack现在为我生成包含我的javascript代码的很好的包。这非常有效,但我想要的是模仿我之前的DevJ时间的RequireJS配置。



当我开发我的应用程序时,我希望Webpack生成一些简单的入口点(就像在RequireJS中一样),它会通过require引用逐个加载我的javascript文件。
与此同时,当我将应用程序部署到服务器时,我仍然希望Webpack执行正常捆绑。



这可以实现吗?

解决方案

启用


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?

解决方案

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

这篇关于如何在Webpack中禁用捆绑以进行开发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆