create-react-app:jquery.themepunch.tools.min.js找不到tweenlite.js

问题描述 投票:0回答:1

我正在构建一个使用create-react-app创建的react应用程序。我在使用jquery插件jquery.themepunch.revolution.min.js时遇到了一些困难。

首先,我将这个库放在src/assets文件夹中,以便webpack可以访问它。然后在我的index.tsx文件中,我这样要求:

要求( “./资产/插件/ RS-插件/ JS / jquery.themepunch.tools.min.js”);

然后我收到这个错误:

./src/assets/plugins/rs-plugin/js/jquery.themepunch.tools.min.js未找到模块:无法解析'C:\ projects \ schoolz \ src \ assets \ plugins \ rs中的'TweenLite' -plugin \ JS'

我验证了tweenlite.js文件确实在文件夹中。

enter image description here

深入研究jquery.themepunch.tools.min.js的源代码,我可以看到调用需要tweenlite.js:

enter image description here

此调用失败。任何建议将不胜感激。

谢谢!

webpack jquery-plugins require create-react-app
1个回答
1
投票

尝试将以下内容添加到Webpack配置文件中:

resolve: {
  root: path.resolve(__dirname),
  extensions: ['', '.js'],
  alias: {
    "TweenLite": "gsap/src/uncompressed/TweenLite" //Path to your TweenLite file
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.