我怎样才能添加速度插件ScrollMagic与NPM?
我需要添加velocityMagic速度插件到我的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') } }