我正在构建一个使用 create-react-app 创建的 React 应用程序。我在使用 jquery 插件 jquery.themepunch.revolution.min.js 时遇到一些困难。
首先,我将此库放在 src/assets
文件夹中,以便 webpack 可以访问它。然后在我的 index.tsx 文件中,我需要这样:
require("./assets/plugins/rs-plugin/js/jquery.themepunch.tools.min.js");
然后我收到此错误:
./src/assets/plugins/rs-plugin/js/jquery.themepunch.tools.min.js Module not found: Can't resolve 'TweenLite' in 'C:\projects\schoolz\src\assets\plugins\rs-plugin\js'
我验证了 tweenlite.js 文件确实位于该文件夹中。
深入研究 jquery.themepunch.tools.min.js 的源代码,我可以看到调用了 tweenlite.js:
此调用失败。任何建议将不胜感激。
谢谢!
最佳答案
尝试将以下内容添加到您的 Webpack 配置文件中:
resolve: {
root: path.resolve(__dirname),
extensions: ['', '.js'],
alias: {
"TweenLite": "gsap/src/uncompressed/TweenLite" //Path to your TweenLite file
}
}
关于webpack - create-react-app:jquery.themepunch.tools.min.js 找不到 tweenlite.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47685567/