Webpack警告:您可能需要适当的加载程序来处理此文件类型(date-nfs) [英] Webpack warning: You may need an appropriate loader to handle this file type (date-nfs)

查看:247
本文介绍了Webpack警告:您可能需要适当的加载程序来处理此文件类型(date-nfs)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序有问题.我有一个网站.我使用date-fns来显示基于用户语言的格式化日期.

I have a problem with my application. I have a website. I use date-fns to show a formatted date based on the user language.

它很好用,但是我已经更新了date-fns,从那时起我就发出了警告.在我的JavaScript代码中,我使用:

It works great, but I have updated date-fns and since then I have a warning. In my JavaScript code I use:

const locale = require(`date-fns/locale/${props.match.params.lang}`)

有了这个,我可以生成正确的格式,如下所示:

And with this, I can generate the right format like this:

format(new Date(), 'D MMMM YYYY', { locale })

它可以工作,但是我不喜欢在构建webpack时收到的警告.您可以帮助我了解我的代码有什么问题吗?如果在webpack配置或包含中.

It works, but I dislike this warning I get when webpack is building. Can you help me to understand what's wrong with my code? If it's in the webpack config or the include.

 You may need an appropriate loader to handle this file type.
>frontend         | > declare module 'date-fns/locale/fr' { }
>frontend         | | 
>frontend         |  @ ./node_modules/date-fns/locale sync ^\.\/.*$ ./fr/index.d.ts
>frontend         |  @ ./assets/javascripts/features/weather/components/home-header.js
>frontend         |  @ ./assets/javascripts/features/weather/components/home.js
>frontend         |  @ ./assets/javascripts/features/weather/containers/home-container.js
>frontend         |  @ ./assets/javascripts/features/weather/containers/app.js
>frontend         |  @ ./assets/javascripts/features/weather/index.js
>frontend         |  @ ./assets/javascripts/app/router.js
>frontend         |  @ ./assets/javascripts/index.js
>frontend         |  @ multi (webpack)-dev-server/client?http://0.0.0.0:3000 ./assets/javascripts/index

推荐答案

尝试一下: const locale = require(date-fns/locale/${props.match.params.lang}/index.js)

Try this: const locale = require(date-fns/locale/${props.match.params.lang}/index.js)

这篇关于Webpack警告:您可能需要适当的加载程序来处理此文件类型(date-nfs)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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