javascript - Webpack's require does work but require.resolve doesn't -


well that's weird, happens. i'm trying use kute.js installed bower, here's config:

webpack config:

var webpack = require("webpack");  module.exports = {   entry: './src/main.js',   output: {     path: './dist',     filename: 'bundle.js'   },   module: {     loaders: [       { test: /\.css$/, loader: 'style-loader!css-loader' },       { test: /\.ttf$/, loader: 'file?name=dist/[name].[ext]' },       { test: require.resolve('zepto'), loader: 'imports?this=>window' },       { test: require.resolve('kute.js'), loader: 'imports?this=>window!expose?kute' },     ],     plugins: [        new webpack.provideplugin({             kute: "kute.js"        })     ]   },   resolve: {     modulesdirectories: ['node_modules', 'bower_components', 'web_modules']   } }; 

my requiring code in src/main.js:

require(['zepto', 'kute.js', 'kute.js/kute-svg'], function() {...}); 

i need plugin , depends on kute global. problem is, when comment out related loader , test resolving (3rd line in loaders), webpack compiles bundle fine, plugin unable load due missing global. if leave is, standard error:

module.js:327     throw err;     ^  error: cannot find module 'kute.js'     @ function.module._resolvefilename (module.js:325:15)     @ function.require.resolve (internal/module.js:16:19)     @ object.<anonymous> (/storage/demo/words/webpack.config.js:14:23)     @ module._compile (module.js:409:26)     @ object.module._extensions..js (module.js:416:10)     @ module.load (module.js:343:32)     @ function.module._load (module.js:300:12)     @ module.require (module.js:353:17)     @ require (internal/module.js:12:17)     @ module.exports (/usr/lib64/node_modules/webpack/bin/convert-argv.js:80:13) 

and meanwhile:

$ ls bower_components kute.js 

how can possible?


Comments