【问题标题】:Issue with materialize-css and Webpack, module with an equal name when case is ignored, JQuerymaterialize-css 和 Webpack 的问题,忽略大小写时具有相同名称的模块,JQuery
【发布时间】:2016-04-29 08:32:26
【问题描述】:

我有一个基本的单页 React/Redux 应用程序,我正在使用 Webpack 捆绑该应用程序,除了在我尝试加载 materialise-css js 文件时出现以下错误外,一切正常。我试过从 NPM 模块加载,编译源和错误是一样的。

WARNING in ./~/jQuery/dist/jquery.js
There is another module with an equal name when case is ignored.
This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.
Rename module if multiple modules are expected or use equal casing if one module is expected.

WARNING in ./~/jquery/dist/jquery.js
There is another module with an equal name when case is ignored.
This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.
Rename module if multiple modules are expected or use equal casing if one module is expected.

我在我的入口文件顶部加载所有内容,如下所示:

import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import ReduxPromise from 'redux-promise';

import App from './components/app'
import reducers from './reducers'

require('../materialize/css/materialize.css');
require('../materialize/js/materialize.js');
require("../style/main.scss");

JQuery 从 NPM 模块加载如下:

new webpack.ProvidePlugin({
        $: "jquery",
        jQuery: "jquery"
})

现在一切仍然正常,它加载了所有字体、js 文件,并且在应用程序中一切正常/看起来正确,但是有一个警告是有原因的,所以我真的想让它消失!

如果您需要更多信息,请告诉我。

你可以在这里查看完整的源代码https://github.com/gazzer82/freeCodeCamp_Recipes

谢谢

【问题讨论】:

    标签: jquery node.js reactjs webpack materialize


    【解决方案1】:

    好的,所以我通过在 materialize.js 中更改它来解决这个问题

    jQuery = $ = require('jQuery');
    

    到这里

    jQuery = $ = require('jquery');
    

    简单。 . . .

    【讨论】:

    • 谢谢,这一定是最新版本的 materialize 中的新内容,以前没有发生过。
    【解决方案2】:

    幸运的是不需要更改 materialize.js :-)

    在 webpack 配置中添加:

    module.exports = {
      // ...
      resolve: {
          alias: {
            jQuery: "path/to/jquery/dist/jquery"
          }
      }
      // ...
    };
    

    更多详情:https://github.com/Dogfalo/materialize/issues/2690

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-12
      • 2012-01-26
      • 1970-01-01
      • 2011-11-30
      • 1970-01-01
      相关资源
      最近更新 更多