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

How can i add velocity plugin to ScrollMagic with npm?

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

package.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')
        }
    }