I need to add scrollMagic with velocity plugin to my npm library.
package.json
{
"name": "library",
"version": "1.0.10",
"description": "blabla",
"main": "index.js",
"dependencies": {
"shortid": "2.x",
"jquery": "2.x",
"scrollmagic": "2.x"
}
}
Is there a way to do that?
Simply adding ScrollMagic does not include plugins.
Please let me know if more info is needed.
EDIT:
If i add the plugin like this: require('scrollmagic/uncompressed/plugins/animation.velocity.js')
I get these error.
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
答案 0 :(得分:1)
我已经在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')
}
}