Webpack:让它忽略找不到的源文件? [英] Webpack: make it ignore source files that can't be found?

查看:45
本文介绍了Webpack:让它忽略找不到的源文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 snabbdom.js 和 webpack 来构建一个 JS 前端应用程序.我有一个非常简单的 snabbdom 视图和捆绑它的 webpack 配置.当我在 chrome 中加载包时,我在控制台中得到了所有这些东西:

I'm using snabbdom.js and webpack to build a JS front-end app. I have a very simple snabbdom view and webpack config that bundles it up. When I load the bundle in chrome I get all this stuff in the console:

我可以将 webpack mode 设置为 production 这确实消除了这些警告,但它也会关闭 all 源映射,所以不是很有帮助.我发现了另一个相关问题 描述如何使用插件加载它们.但是我不想为我实际上不想要的源映射配置插件而烦恼.有没有办法告诉 webpack 忽略这些?

I can set the webpack mode to production which does get rid of these warnings but it also turns off all source maps, so that's not really helpful. I found this other related question that describes how to use a plugin to load them. But I don't want to mess around with configuring a plugin for source maps I don't actually want. Is there a way to tell webpack to just ignore these?

推荐答案

我在 webpack devtools 选项 并发现添加devtool: 'eval-cheap-source-map', 到我的 webpack 配置就可以了.

I read up a bit more on the details of each option in the webpack devtools options and found that adding devtool: 'eval-cheap-source-map', to my webpack config did the trick.

来自文档:

它没有列映射,它只映射行号.它忽略来自加载器的 SourceMaps,只显示类似于 eval devtool 的转译代码

it doesn't have column mappings, it only maps line numbers. It ignores SourceMaps from Loaders and only display transpiled code similar to the eval devtool

这篇关于Webpack:让它忽略找不到的源文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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