小编Cyr*_*ret的帖子

Webpack 警告:您可能需要合适的加载程序来处理此文件类型 (date-nfs)

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

它工作得很好,但我已经更新了 date-fns,从那以后我有一个警告。在我的 JavaScript 代码中,我使用:

const locale = require(`date-fns/locale/${props.match.params.lang}`)
Run Code Online (Sandbox Code Playgroud)

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

format(new Date(), 'D MMMM YYYY', { locale })
Run Code Online (Sandbox Code Playgroud)

它有效,但我不喜欢在构建 webpack 时收到的这个警告。你能帮我理解我的代码有什么问题吗?如果它在 webpack 配置或包含中。

 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         | …
Run Code Online (Sandbox Code Playgroud)

warnings include loader webpack date-fns

3
推荐指数
1
解决办法
563
查看次数

标签 统计

date-fns ×1

include ×1

loader ×1

warnings ×1

webpack ×1