Trying to require parts of jquery with webpack

Viewed 1479

I am using this article to import only the parts of jquery that I would need.

However, I am running into an issue when doing using this code:

let $ = require('jquery/src/core');
require('jquery/src/core/init');
require('jquery/src/css');
console.log($);

I get this error:

ERROR in ./~/jquery/src/selector-sizzle.js
Module not found: Error: Cannot resolve 'file' or 'directory' ../external/sizzle/dist/sizzle in /home/vamsi/Do/highland-fun/bacon-form/node_modules/jquery/src
 @ ./~/jquery/src/selector-sizzle.js 1:0-14:3

This is my webpack.config.js file:

module.exports = {
    entry:'./app',
    output:{
      filename:'./bundle'
    },
    modules:{
      loaders:[
        {
           test:/jquery[\\\/]src[\\\/]selector\.js$/,
           loaders:['amd-define-factory-patcher-loader']
        }
      ]
    }
}

I have tried to use a resolve.alias to fix this:

resolve:{                                                                
  alias:{                                                                
   '../external/sizzle/dist/sizzle':'./node_modules/sizzle/dist/sizzle.js'
  }                                                                      
}

But it still throws the same error as before.

1 Answers
Related