gpt4 book ai didi

javascript - 如何使用 npm 将速度插件添加到 ScrollMagic?

转载 作者:行者123 更新时间:2023-11-30 00:11:15 25 4
gpt4 key购买 nike

我需要将带有 velocity 插件的 scrollMagic 添加到我的 npm 库中。

包.json

{
"name": "library",
"version": "1.0.10",
"description": "blabla",
"main": "index.js",
"dependencies": {
"shortid": "2.x",
"jquery": "2.x",
"scrollmagic": "2.x"
}
}

有办法吗?

单纯添加ScrollMagic不包含插件

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

编辑:

如果我这样添加插件:require('scrollmagic/uncompressed/plugins/animation.velocity.js')

我收到这些错误。

    ERROR in ./~/scrollmagic/scrollmagic/uncompressed/plugins/animation.velocity.js
Module not found: Error: Cannot resolve module 'ScrollMagic' in /home/av/local.dev/testest/node_modules/scrollmagic/scrollmagic/uncompressed/plugins
@ ./~/scrollmagic/scrollmagic/uncompressed/plugins/animation.velocity.js 31:2-46

ERROR in ./~/scrollmagic/scrollmagic/uncompressed/plugins/animation.velocity.js
Module not found: Error: Cannot resolve module 'velocity' in /home/av/local.dev/testest/node_modules/scrollmagic/scrollmagic/uncompressed/plugins
@ ./~/scrollmagic/scrollmagic/uncompressed/plugins/animation.velocity.js 31:2-46

最佳答案

我在 webpack.config.js 中添加了这些库来解决这个问题:

resolve: {
extensions: ['', '.js', '.json'],
root: [Path.join(__dirname, "node_modules")],
modulesDirectories: ['node_modules'],
alias: {
"ScrollMagic": Path.resolve('node_modules', 'scrollmagic/scrollmagic/minified/ScrollMagic.min.js'),
"animation.velocity": Path.resolve('node_modules', 'scrollmagic/scrollmagic/minified/plugins/animation.velocity.min.js'),
"velocity": Path.resolve('node_modules', 'velocity-animate/velocity.min.js')
}
}

关于javascript - 如何使用 npm 将速度插件添加到 ScrollMagic?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36408862/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com